Forum Discussion
Running Total Balance based on pulling history
Hi,
i am new here do if something is not clear i will add π
in my company there is a table of deals and table of orders - from each deal let say 100000 the customer can pull from his deal the products he want till he finished the 100000
on each time, the ERP server of the system update the deal balance as given value and not giving me the balance for each date.
i tried to calculate the running balance by myself based on the orders date(UDATE) and the orders amount(Qprice)
my measure as below:
4 Replies
- bhanu_gautam
Super User
avi123 , Try using below measure
RunningTotalBalance =
VAR CurrentDeal = MAX(DEAL_Alpha[DEAL])
VAR CurrentDate = MAX(ORDERS_Alpha[UDATE])
VAR DealInitialBalance = MAXX(FILTER(DEAL_Alpha, DEAL_Alpha[DEAL] = CurrentDeal), DEAL_Alpha[QPRICE])
VAR OrdersTotal = CALCULATE(
SUM(ORDERS_Alpha[QPRICE]),
FILTER(
ALL(ORDERS_Alpha),
ORDERS_Alpha[DEAL] = CurrentDeal &&
ORDERS_Alpha[UDATE] <= CurrentDate
)
)
RETURN
DealInitialBalance - OrdersTotal- avi123New Member
bhanu_gautam
Hitx for the help but it giving me the same result and still 0 in the total per the cust_ID
- AnonymousNot applicable
Hi avi123
Thank you very much bhanu_gautam for your prompt reply. Allow me to share something.
You can try adjusting the measure to make sure it handles each customer and transaction correctly:
RunningTotalBalance = VAR CurrentDeal = MAX(DEAL_Alpha[DEAL]) VAR CurrentDate = MAX(ORDERS_Alpha[UDATE]) VAR DealAmount = MAXX(FILTER(ALL(DEAL_Alpha), DEAL_Alpha[DEAL] = CurrentDeal), DEAL_Alpha[QPRICE]) VAR OrdersToDate = CALCULATE( SUM(ORDERS_Alpha[QPRICE]), FILTER( ALL(ORDERS_Alpha), ORDERS_Alpha[DEAL] = CurrentDeal && ORDERS_Alpha[UDATE] <= CurrentDate ) ) RETURN DealAmount - OrdersToDateIf you're still having problems, please provide sample data that fully covers your issue and the expected outcome based on the sample data you provided.
Regards,
Nono Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Ashish_Mathur
Super User
Hi,
Share some data to work with and show the expected result. Share data in a format that can be pasted in an MS Excel file.