Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.
Hi There,
I need help with DAX taht will show totals correctly.
In Totals I only want to have a sum of elements where last month is not blank.
Sample Table:
GROUP | ID | Month | Value |
A | 1 | 1 | 1 |
A | 1 | 2 | 2 |
A | 2 | 1 | 1 |
A | 2 | 2 | 2 |
A | 2 | 3 | 3 |
B | 3 | 1 | 1 |
B | 3 | 2 | 2 |
B | 3 | 3 | 1 |
B | 4 | 1 | 1 |
B | 4 | 2 | 2 |
And the desired result in Matrix should be like this:
GROUP | ID | Month 1 | Month 2 | Month 3 | Total | |
A TOTAL | 2 | 4 | 3 | 6 | 6 Because For ID 1 lastMonth is blank so we only sum ID 2 | |
1 | 1 | 2 | 0 | 0 Because Last month is Blank | ||
2 | 1 | 2 | 3 | 6 | Last Month ist not blank so we sum all months for that ID | |
B TOTAL | 2 | 2 | 1 | 4 | 4 becasue For ID 4 last Month is blank so we only sum ID 3 | |
3 | 1 | 2 | 1 | 4 | Last Month ist not blank so we sum all months for that ID | |
4 | 1 | 0 | 0 Because Last month is Blank | |||
GRAND TOTAL | 4 | 6 | 4 | 10 |
Weird Sum =
SUMX(
VALUES( 'Sample'[ID] ),
CALCULATE(
IF(
MAX( 'Sample'[Month] )
<> CALCULATE( MAX( 'Sample'[Month] ), REMOVEFILTERS( 'Sample'[ID] ) ),
0,
SUM( 'Sample'[Value] )
)
)
)
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LearnAndPractise(Everyday) ) |
Total = IF(HASONEVALUE('Table'[Month]), SUM('Table'[Value]),
VAR last_month=CALCULATE(MAX('Table'[Month]),ALL())
VAR last_ids = CALCULATETABLE(VALUES('Table'[ID]), ALL(), 'Table'[Month]=last_month)
RETURN CALCULATE(SUM('Table'[Value]), KEEPFILTERS(last_ids)) + 0
)