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
Anonymous
Not applicable

Power Query: Generate Queries based on Distinct Values.

Good Morning, Community:

I have this table, which contains demand for specific items, on a given location and a given date:

DateProduct ID Location IDDemand (Qty)
01-01-2018a34
01-02-2018b130
01-03-2018c47
01-04-2018e310
01-05-2018d317
01-06-2018a319
01-07-2018b144
01-08-2018c323


Assuming the demand is already grouped (Sum) by Date, Product ID and Location ID, is there a way of generating several queries based distinct Product IDs and Location IDs, containing their respective demand?

This how it would look like for product "a" on location "3":

DateProduct ID Location IDDemand (Qty)
01-01-2018a34
01-06-2018a319


Thanks in advance.

1 ACCEPTED SOLUTION
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

This is easy to do with DAX. But if you'd like the Power Query solution, please refer to the following steps.

1. Create a function.

(ProductID as text, LocationID as number) as table=>

let
    result = Table.SelectRows(Table1, each [Product ID] = ProductID and [Location ID] = LocationID)
in
    result

2. Invoke the function with parameters.

Power-Query-Generate-Queries-based-on-Distinct-Values

Please download the demo in the attachment. 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

1 REPLY 1
v-jiascu-msft
Employee
Employee

Hi @Anonymous,

 

This is easy to do with DAX. But if you'd like the Power Query solution, please refer to the following steps.

1. Create a function.

(ProductID as text, LocationID as number) as table=>

let
    result = Table.SelectRows(Table1, each [Product ID] = ProductID and [Location ID] = LocationID)
in
    result

2. Invoke the function with parameters.

Power-Query-Generate-Queries-based-on-Distinct-Values

Please download the demo in the attachment. 

 

Best Regards,
Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

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.