The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hello, how to write a dax formula to sum up all values from the column value based on the following conditions?
First condition is that we need to group by ID1
Second condition is that we only sum values from the max value of ID2
ID1 | ID2 | Value |
12 | 5543 | 100 |
31 | 4125 | 150 |
31 | 6412 | 50 |
31 | 1333 | 300 |
In this case the sum should return 100+50=150.
Solved! Go to Solution.
Try this measure:
Sum of Max Value =
VAR vBaseTable =
ADDCOLUMNS (
VALUES ( 'Table'[ID1] ),
"@MaxID2", CALCULATE ( MAX ( 'Table'[ID2] ) )
)
VAR vFilterTable =
TREATAS ( vBaseTable, 'Table'[ID1], 'Table'[ID2] )
VAR vResult =
CALCULATE ( SUM ( 'Table'[Value] ), vFilterTable )
RETURN
vResult
Proud to be a Super User!
Try this measure:
Sum of Max Value =
VAR vBaseTable =
ADDCOLUMNS (
VALUES ( 'Table'[ID1] ),
"@MaxID2", CALCULATE ( MAX ( 'Table'[ID2] ) )
)
VAR vFilterTable =
TREATAS ( vBaseTable, 'Table'[ID1], 'Table'[ID2] )
VAR vResult =
CALCULATE ( SUM ( 'Table'[Value] ), vFilterTable )
RETURN
vResult
Proud to be a Super User!
User | Count |
---|---|
79 | |
78 | |
37 | |
33 | |
31 |
User | Count |
---|---|
93 | |
81 | |
59 | |
49 | |
48 |