cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
J-Saw Frequent Visitor
Frequent Visitor

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

Accepted Solutions
v-jiascu-msft Super Contributor
Super Contributor

Re: Power Query: Generate Queries based on Distinct Values.

Hi @J-Saw,

 

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 Super Contributor
Super Contributor

Re: Power Query: Generate Queries based on Distinct Values.

Hi @J-Saw,

 

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

Helpful resources

Announcements
Can You Solve These Challenge

Challenge: Can You Solve These?

Find out how to participate in the first Power BI 'Can You Solve These?' challenge.

Community News & Announcements

Community News & Announcements

Get your latest community news and announcements.

Virtual Launch Event

Microsoft Business Applications October Virtual Launch Event

Join us for an in-depth look at the new innovations across Dynamics 365 and the Microsoft Power Platform.

Community Kudopalooza

Win Power BI Swag with Community Kudopalooza!

Each week, complete activities and be qualified in the drawing for cool Power BI Swag.

Users Online
Currently online: 306 members 3,588 guests