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.
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 | |
10 | |
8 | |
6 | |
6 |
User | Count |
---|---|
31 | |
12 | |
10 | |
10 | |
9 |