Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Is there a way to create a measure that returns the sum of a column for each row grouped by two conditions without using the group by feature in Power Query? Here is some sample data to explain:
The measure would have to return the total cost for each customer split up by each Product ID. For example, if I used this measure in a calculated column, the measure would return 6 not 3 for the second to last row. I can not group the columns in Power Query because I need the months. I tried to use calculate and filter by Customer ID >= Earlier(Customer ID) and Product ID >= Earlier (Product ID) after sorting both columns in the Power Query but this did not seem to work due to the size of the table I am working with.
Thank you!
Solved! Go to Solution.
@srpeters Try this (below) You can use the measure in a table visual with Customer ID and Product ID
Column =
VAR __Customer = [Customer ID]
VAR __Product = [Product ID]
VAR __Table = FILTER( 'Table', [Custmer ID] = __Customer && [Product ID] = __Product )
VAR __Result = SUMX( __Table, [Cost] )
RETURN
__Result
Measure =
VAR __Customer = MAX( [Customer ID] )
VAR __Product = MAX( [Product ID] )
VAR __Table = FILTER( 'Table', [Custmer ID] = __Customer && [Product ID] = __Product )
VAR __Result = SUMX( __Table, [Cost] )
RETURN
__Result
Hi @srpeters
Here is the solution
Hi @srpeters
Here is the solution
This worked great, thank you!
@srpeters Try this (below) You can use the measure in a table visual with Customer ID and Product ID
Column =
VAR __Customer = [Customer ID]
VAR __Product = [Product ID]
VAR __Table = FILTER( 'Table', [Custmer ID] = __Customer && [Product ID] = __Product )
VAR __Result = SUMX( __Table, [Cost] )
RETURN
__Result
Measure =
VAR __Customer = MAX( [Customer ID] )
VAR __Product = MAX( [Product ID] )
VAR __Table = FILTER( 'Table', [Custmer ID] = __Customer && [Product ID] = __Product )
VAR __Result = SUMX( __Table, [Cost] )
RETURN
__Result
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
18 | |
15 | |
12 | |
10 | |
8 |
User | Count |
---|---|
24 | |
17 | |
11 | |
11 | |
10 |