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.
I have a challenge on a Specific DAX formula.
I have one tabel containing A CustomerID, Week and a Value. I would like to add a Calculated Collumn that sums the Value of the Specific Customer in the Same Week.
It should look like the result below;
Cust | Week | Value | SUM
A | 1 | 2,5 | 6,5
A | 1 | 4 | 6,5
A | 2 | 2,5 | 5
A | 2 | 2,5 | 5
B | 1 | 5 | 6
B | 1 | 2 | 6
B | 2 | 5 | 10
B | 2 | 5 | 10
C | 1 | 8 | 8
C | 2 | 8 | 8
C | 3 | 8 | 8
C | 4 | 8 | 8
I've treid using CALCULATE, SUM and SUMX but i wasn't albe to create the above results.
I've also read different items on the "SUMIF" function but i couldn't find a way of sum that checks 2 identifying collumns (Cust. and Week)
I hope that someone could help me on this matter?
Solved! Go to Solution.
hi @Z4m
You can do it with this calculated column:
you can also try a DAX expression as
SUM = SUMX ( FILTER ( 'Table', EARLIER ( 'Table'[Cust] ) = 'Table'[Cust] && EARLIER ( 'Table'[Week] ) = 'Table'[Week] ), 'Table'[Value] )
@Eric_Zhang The solution you gave resulted in a cullumative collumn, i got it solve by another post.
But thanks for your advice!
Why not just create a simple sum and use your week numbers from your date table? Put week numbers on a row then add customer ID. Use your sum for the values. One sum expression could then be used in multiple iterations.
Proud to be a Super User!
hi @Z4m
You can do it with this calculated column:
There's likely a way to do this in DAX that I haven't learned yet, but one option in Power BI is to create a new table (Modeling -> New Table) with the following formula:
NewTable = SUMMARIZE('OriginalTable', 'OriginalTable'[Cust], 'OriginalTable'[Week], "Sum of Values" , SUM('OriginalTable'[Value]))
This will add the additional column that sums the VALUE column based on grouping of Customer and Week Number. You can then build a visual based on NewTable columns Cust, Week, and Sum of Values to get the results you've provided.
Thanks,
Sam Lester (MSFT)
Not really sure I get what you're trying to do, but would something like IF([Customer ID] = X,SUM([Value],Something else)) where X is the particular customer id?
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
112 | |
100 | |
80 | |
64 | |
57 |
User | Count |
---|---|
146 | |
110 | |
93 | |
84 | |
67 |