The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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 |
---|---|
83 | |
83 | |
37 | |
34 | |
32 |
User | Count |
---|---|
92 | |
79 | |
62 | |
53 | |
51 |