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.
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 |
---|---|
83 | |
83 | |
37 | |
34 | |
32 |
User | Count |
---|---|
92 | |
79 | |
62 | |
53 | |
51 |