Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in BI by (11.1k points)

I want to create two parameters Date from and Date to, and I want to write a query so I first created dates StartDate and EndDate and I am getting the following error

can't convert from data type Record to Text". Do you know what's wrong with it?

enter image description here

and I had a code

let
    Source = Sql.Database("Server\12", "Base1"),

        Query = Value.NativeQuery(
            Source, 
            [Query="EXEC [dbo].[sp_Sales] @DateFrom = '" & Date.ToText(StartDate) & "', @DateTo = '" & Date.ToText(EndDate) & "'"])
  
in  

 Query 

let
    Source = Sql.Database("Server\12", "Base1"),

        Query = Value.NativeQuery(
            Source, 
            [Query="EXEC [dbo].[sp_Sales] @DateFrom = """ & Date.ToText(StartDate) & """, @DateTo = """ & Date.ToText(EndDate) & """"])
  
in  

 Query 

1 Answer

0 votes
by (22.5k points)
edited by
  • Create a parameter and import the data in Power Bi
  • Create two parameters in Power Editor and mention the start date and end date by giving some default values

          enter image description here

  • Advance editor, give the following code

         let

    Source = Sql.Database("ServerName\12", "Base2"),
    Query = Value.NativeQuery(
            Source, 
            "EXEC [dbo].[storedProcedure_XYZ] @DateFrom = '" & Date.ToText(startDate) & "', @DateTo = '" & Date.ToText(endDate) & "'")
    
in
    
Query    
  • Go to Transform data and edit parameters
  • edit parameters

        enter image description here

 If u want to learn more, come to this Power BI Certification.

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jan 13, 2021 in BI by Chris (11.1k points)
0 votes
1 answer
asked Jan 18, 2021 in BI by Chris (11.1k points)

Browse Categories

...