Forum Discussion
Help w/Tricky Issue: Disconnected Table DAX Bucketing
After looking into this, I'm actually a little confused on how to best set this up. Can you elaborate on what you're thinking?
I created a Calculated Column in Collections to store the Rolling Balance. Unfortunately, the measure I wrote actually ended up slower than the original. I still don't know of a way to not need to clear the Collections[As Of Date] filter to get the Outstanding Balance, which likely slows things down.
Am I missing something?
Updated .pbix: drive.google.com/file/d/128rvGqMmCFjvAUBMmr9x06Z1fjStihJW/view?usp=sharing
VAR AsOfDate = MIN( MAX('xAs Of Date'[As Of Date]), TODAY() ) // Earlier of the latest As Of Date in the original filter context or Today. Use MAX so it still works when rolled up to year or when there is no filter applied
VAR LastValue = CALCULATETABLE(
TOPN( 1
, SUMMARIZE(Collections, Collections[Document Key], Collections[From Document Key], Collections[As Of Date])
, Collections[As Of Date], DESC, Collections[From Document Key], DESC
)
, 'xAs Of Date'[As Of Date] <= AsOfDate
/*** This section is surprisingly faster, but still slower than the original measure ***/
// , FILTER( ALL(Collections[As Of Date])
// , Collections[As Of Date] <= AsOfDate
// )
// , CROSSFILTER('xAs Of Date'[As Of Date], Collections[As Of Date], NONE)
)
VAR Balance = CALCULATE(
SUM(Collections[RollingFuncAmt])
, LastValue
, 'xAs Of Date'[As Of Date] <= AsOfDate
// , CROSSFILTER('xAs Of Date'[As Of Date], Collections[As Of Date], NONE)
)
VAR Final = IF(ROUNDDOWN(ABS(Balance), 0) = 0, BLANK(), Balance) // Hide 0 Balances & pennies remaining from bad GP data
RETURN Final
You have to pre-calculate the balances not in DAX but in the source system (SQL Server, right?) or in Power Query. Then and only then will it make a lot of sense.
- ryan25r95 years ago
Helper I
Not sure what you mean. I calculated it in SQL as well and it's the same as the DAX Calculated Column.