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.
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.LeanAndPractise(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
)
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 |
---|---|
21 | |
15 | |
14 | |
11 | |
7 |
User | Count |
---|---|
25 | |
24 | |
12 | |
11 | |
11 |