Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
GAPER
Post Patron
Post Patron

Snowflake Dynamic Query failed

Here is the code. The error I got is 

 

Expression.Error: We cannot convert a value of type Record to type Text.
Details:
Value=[Record]
Type=[Type]

 

I am trying to create a dynamic query where i can use a filter in the PowerBI UI to determine what dates i am returning from snowflake. Thanks!

 

let
    selectedDates = if Type.Is(Value.Type(DateMParameter), List.Type) then 
      Text.Combine({"'", Text.Combine(DateMParameter, "','") , "'"})
    else
      Text.Combine({"'" , DateMParameter , "'"}),

    selectAllCountries = if Type.Is(Value.Type(DateMParameter), List.Type) then 
      List.Contains(DateMParameter, "__SelectAll__")
    else
      false,

    query = "SELECT #(lf)*#(lf)#(lf)FROM LANDING.HIDDEN.POWERBIPROJECTSUMMARY",

    dynamicFilter = if selectAllDates then " "
                    else  Text.Combine({" WHERE Date in(", selectedDate, ")"}),

    finalQuery = Text.Combine({query, dynamicFilter}),

    Source = Value.NativeQuery(Snowflake.Databases("HIDDEN.southeast-asia.azure.snowflakecomputing.com","POWERBI_WH"){[Name="LANDING"]}[Data], [Query=finalQuery], null, [EnableFolding=true])

in
    Source

 

1 REPLY 1
jpessoa8
Super User
Super User

Hi @GAPER,

 

The issue will probably be related with DateMParameter.. Can you provide it's query and/or results?


Best regards,
Jorge Pessoa

Helpful resources

Announcements
Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.