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.
Here is my measure:
Cash Balance [GBP]:=VAR CorrectTable =
ADDCOLUMNS (
GROUPBY (
Projected_Cash_Balances,
Projected_Cash_Balances[Country],
Projected_Cash_Balances[Dates]
),
"Last Balance [GBP]", SUMX (
FILTER (
Projected_Cash_Balances,
[Index] = MAX ( [Index] )
&& LASTDATE ( Projected_Cash_Balances[Dates] )
),
[Balance [GBP]]]
)
)
RETURN
AVERAGEX ( CorrectTable, AVERAGE ( [Last Balance [GBP]]] ) )
Attached is my input table, and a pivot table. The cell highlighted in yellow is wrong... : ( (it should be 79,723)
Thanks in advance,
Sachin
Solved! Go to Solution.
ok, problem now solved
VAR CorrectTable =
ADDCOLUMNS (
GROUPBY (
Projected_Cash_Balances,
Projected_Cash_Balances[Country],
Projected_Cash_Balances[Dates]
),
"Last Balance [GBP]", AVERAGEX (
FILTER (
Projected_Cash_Balances,
[Index]
= MAXX (
FILTER (
Projected_Cash_Balances,
[Country] = EARLIER ( [Country] )
&& [Dates] = MAX ( [Dates] )
),
[Index]
)
),
[Balance [GBP]]]
)
)
RETURN
SUMX (
FILTER ( CorrectTable, [Dates] = MAX ( [Dates] ) ),
[Last Balance [GBP]]]
)
This looks like a measure totals problem. Very common. See my post about it here: https://community.powerbi.com/t5/DAX-Commands-and-Tips/Dealing-with-Measure-Totals/td-p/63376
Also, this Quick Measure, Measure Totals, The Final Word should get you what you need:
https://community.powerbi.com/t5/Quick-Measures-Gallery/Measure-Totals-The-Final-Word/m-p/547907
Thanks for the suggested help.
I read through both links, but am still struggling with my specific problem.
The totals are not always wrong. Just wrong on some days....
With updated DAX below (but it is still not working....) = [
Cash Balance [GBP]:=VAR CorrectTable =
ADDCOLUMNS (
GROUPBY (
Projected_Cash_Balances,
Projected_Cash_Balances[Country],
Projected_Cash_Balances[Dates]
),
"Last Balance [GBP]", AVERAGEX (
FILTER (
Projected_Cash_Balances,
[Index] = MAX ( [Index] )
&& [Country] = EARLIER([Country])
&& [Dates] = MAX([Dates])),
[Balance [GBP]]]
)
)
RETURN
SUMX ( FILTER(CorrectTable, [Dates] = MAX([Dates] )), [Last Balance [GBP]]])
ok, problem now solved
VAR CorrectTable =
ADDCOLUMNS (
GROUPBY (
Projected_Cash_Balances,
Projected_Cash_Balances[Country],
Projected_Cash_Balances[Dates]
),
"Last Balance [GBP]", AVERAGEX (
FILTER (
Projected_Cash_Balances,
[Index]
= MAXX (
FILTER (
Projected_Cash_Balances,
[Country] = EARLIER ( [Country] )
&& [Dates] = MAX ( [Dates] )
),
[Index]
)
),
[Balance [GBP]]]
)
)
RETURN
SUMX (
FILTER ( CorrectTable, [Dates] = MAX ( [Dates] ) ),
[Last Balance [GBP]]]
)
User | Count |
---|---|
25 | |
12 | |
8 | |
6 | |
6 |
User | Count |
---|---|
26 | |
12 | |
12 | |
10 | |
6 |