Forum Discussion
Beginning balance
- Anonymous7 years ago
I've taken a look and created a power bi file with your model and relationships. I've used variables in the measures to identify which amounts have been worked in a selected period and which have been paid based on the WDate and the WIPDate. The Unpaid Amount decreases to zero once you reach the end of the date range as one the final WIP Date, all amounts worked are paid.
Here are the formulas:
Amount Worked at start of Period =VAR MinSelectedWorkingDate = MIN('Calendar'[Date])RETURN (CALCULATE(SUM(Data[Value]), FILTER(ALL(Data), Data[WDate] < MinSelectedWorkingDate)))Amount Worked in Period = CALCULATE(SUM(Data[Value])) // This uses the default relationship from WDate to Calendar to ensure amount is in the selected periodAmount Worked at end of period = [Amount Worked at start of Period] + [Amount Worked in Period]Here are the Billed amounts:Amount Billed at start of Period =VAR MinSelectedWorkingDate = MIN('Calendar'[Date])RETURN (CALCULATE(SUM(Data[Value]), FILTER(ALL(Data), Data[WIPDate] < MinSelectedWorkingDate)))Amount Billed in Period = CALCULATE(SUM(Data[Value]), USERELATIONSHIP('Calendar'[Date], Data[WIPDate]))//This uses the USERELATIONSHIP function to switch to the inactive relationship from WIPDate to Calendar DateAmount Billed at end of Period = [Amount Billed at start of Period] + [Amount Billed in Period]Here are the amounts outstanding:Amount Owed at Start of period = [Amount Billed at start of Period] - [Amount Worked at start of Period]Amount Owed at End of Period = [Amount Billed at end of Period] - [Amount Worked at end of period]I hope this solves your problem. - please mark as Solved :)
I've taken a look and created a power bi file with your model and relationships. I've used variables in the measures to identify which amounts have been worked in a selected period and which have been paid based on the WDate and the WIPDate. The Unpaid Amount decreases to zero once you reach the end of the date range as one the final WIP Date, all amounts worked are paid.
Here are the formulas:
I hope this solves your problem. - please mark as Solved :)
- Anonymous7 years agoNot applicable
Anonymousthanks! Sublimely clever. I understand each, but I am facing a new problem that I think is created by ALL. To be fair, I did not include a dimension that is important. Each of those time entry lines is assigned to a client. I need to come up with the beginning and ending balances by client. However, if I am thinking correctly, the ALL command removes the relationship between the client dimension and the filter. Therefore I get a pivot table with the same value for every client ID. Except in the two cases of "In Period". Can you see a way around this new issue?
- Anonymous7 years agoNot applicable
AnonymousThis may help explain my further dilemma. Here is a screen shot of my test pivot table against my SSAS tabular model using your formulas.
- Anonymous7 years agoNot applicable
AnonymousI inserted an ALLEXCEPT into the formula...
Amount worked at start of period:=
VAR MinSelectedWorkingDate = MIN('Date'[Date])
RETURN (CALCULATE([Sum of Wfee]+[Sum of Wexp],
FILTER(ALLEXCEPT(WIP,WIP[ClientKey],WIP[ClientEngKey]),WIP[Wdate]<MinSelectedWorkingDate)))
...and the numbers react now to dropping ClientEngKey onto the pivot rows. However, the user will pick the "name" from the dim.Client table and the ALLEXCEPT only allows for filtering directly in the fact table (WIP). Progress though.
One more question - what's the advantage of using the variable rather than just typing MIN('Date'[Date]) after the < sign at the end of the formula? Best practice? Performance?