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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
AlanCruz
Frequent Visitor

How to convert a query to a parameter?

Hi everyone, I have two queries A and B, query A is my main data source and query B is a json file that I use for both power BI and a python application we use here.

 

I would like to know how I can import just one field from my query B and convert it to a parameter to filter the data from my query A.

 

I can do this with a parameter manually changing the value when necessary, but I would like to do this through my json file, because that way would update other reports that use the same parameter.

1 ACCEPTED SOLUTION

I put it together in one query, but I think it demostrates the idea:

let 
    B = 
        let
            Source = "{""a"":1}",
            Use = Json.Document("{""name"":""John"", ""age"":30, ""car"":null}")[age]
        in Use,
    A = 
        let             
            t = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQitWJVjKCUMYQygRIxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ages = _t]),
            #"Filtered Rows" = Table.SelectRows(t, each (Number.From([Ages]) = B))
        in #"Filtered Rows"
in A

Above query B returns a number (age) from the JSON string and then query A refers to query B (essentially, uses the number it returns) to use as a filter.

 

Cheers,

John

View solution in original post

3 REPLIES 3
Greg_Deckler
Super User
Super User

@AlanCruz 

Greg_Deckler_0-1664916577808.png

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  I did as indicated, but my parameter is empty.

AlanCruz_0-1664970868066.png

I would like that single item in the list to become the value of my parameter.

AlanCruz_1-1664970895568.png

Is it possible to do this?

I put it together in one query, but I think it demostrates the idea:

let 
    B = 
        let
            Source = "{""a"":1}",
            Use = Json.Document("{""name"":""John"", ""age"":30, ""car"":null}")[age]
        in Use,
    A = 
        let             
            t = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjRQitWJVjKCUMYQygRIxQIA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Ages = _t]),
            #"Filtered Rows" = Table.SelectRows(t, each (Number.From([Ages]) = B))
        in #"Filtered Rows"
in A

Above query B returns a number (age) from the JSON string and then query A refers to query B (essentially, uses the number it returns) to use as a filter.

 

Cheers,

John

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors
Top Kudoed Authors