Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.
Hi everyone
I'm using the following DAX measure to calculate the latest gift amount per customer:
Solved! Go to Solution.
Try this measure:
LatestValue_Nett =
// calculate total amount for each date/person
VAR vBaseTable =
ADDCOLUMNS (
'transaction',
"@Amount",
CALCULATE (
SUM ( 'transaction'[dc1amount] ) + SUM ( 'transaction'[dc2amount] )
+ SUM ( 'transaction'[dc3amount] )
)
)
// calculate max amount for each date/person
VAR vMaxTable =
ADDCOLUMNS (
vBaseTable,
"@MaxAmount",
VAR vDate = 'transaction'[dateofpayment]
VAR vPerson = 'transaction'[person]
RETURN
MAXX (
FILTER (
vBaseTable,
'transaction'[dateofpayment] = vDate
&& 'transaction'[person] = vPerson
),
[@Amount]
)
)
// sum max amount for each date/person
VAR vResult =
SUMX ( FILTER ( vMaxTable, [@Amount] = [@MaxAmount] ), [@Amount] )
RETURN
vResult
Here's the result using the sample data below:
Proud to be a Super User!
Try this measure:
LatestValue_Nett =
// calculate total amount for each date/person
VAR vBaseTable =
ADDCOLUMNS (
'transaction',
"@Amount",
CALCULATE (
SUM ( 'transaction'[dc1amount] ) + SUM ( 'transaction'[dc2amount] )
+ SUM ( 'transaction'[dc3amount] )
)
)
// calculate max amount for each date/person
VAR vMaxTable =
ADDCOLUMNS (
vBaseTable,
"@MaxAmount",
VAR vDate = 'transaction'[dateofpayment]
VAR vPerson = 'transaction'[person]
RETURN
MAXX (
FILTER (
vBaseTable,
'transaction'[dateofpayment] = vDate
&& 'transaction'[person] = vPerson
),
[@Amount]
)
)
// sum max amount for each date/person
VAR vResult =
SUMX ( FILTER ( vMaxTable, [@Amount] = [@MaxAmount] ), [@Amount] )
RETURN
vResult
Here's the result using the sample data below:
Proud to be a Super User!
User | Count |
---|---|
107 | |
89 | |
81 | |
76 | |
73 |
User | Count |
---|---|
112 | |
104 | |
96 | |
74 | |
66 |