Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance 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!