Forum Discussion
Show declining account balances
Hi,
I have data which shows a list of customer ID's and their account balances for each month. I need to build a report which will pull only the customer with declining balances over the last rolling 12 months. I am not sure how to calculate if a customer is having a declining balance. We would like to start with anyone with a 25% decrease from 12 months ago to the current date. I have a date table.
Thank you!
- Anonymous3 years ago
Hi KW123
Try the code below:
Measure 2 = var a=FILTER(ALLSELECTED('Table'),'Table'[ Customer ID]=SELECTEDVALUE('Table'[ Customer ID])) var b= MAXX(FILTER(a,[Date]=MAXX(ALLSELECTED('Table 2'[Date]),[Date])),[ Balance]) VAR c=MINX(FILTER(a,[Date]=MINX(ALLSELECTED('Table 2'[Date]),[Date])),[ Balance]) var d= DIVIDE(b-c,b,0) return if(d<=-0.25,1,0)then put the measure into the visual filter
Best Regards,
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
14 Replies
- lbendlinSuper User
Please provide sanitized sample data that fully covers your issue.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216
Please show the expected outcome based on the sample data you provided.
https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523- KW123Helper V
lbendlin
Here is an example of what the data looks likeDate Customer ID Customer Balance 11/30/2022 123 $535 11/30/2022 234 $1045 11/30/2022 345 $324 10/31/2022 123 $525 10/31/2022 234 $1025 10/31/2022 345 $300 09/30/2022 123 $948 09/30/2022 234 $1000 09/30/2022 345 $489
It tracks each customer ID account balances until the end of time. I need to write a dax which will show only the customer ID who have had a 25% decrease in the balance from 12 months ago (a rolling 12 months) to current date.
I hope that clarifies- AnonymousNot applicable
Hi KW123
You can create a measure :
Measure 2 = var a=FILTER(ALL('Table (4)'),'Table (4)'[Customer]=SELECTEDVALUE('Table (4)'[Customer]))var b= MAXX(FILTER(a,'Table (4)'[Date]=MAXX(a,[Date])),[CB])VAR c=MINX(FILTER(a,'Table (4)'[Date]=MINX(a,[Date])),[CB])var d= DIVIDE(b-c,b,0)return if(d<=-0.25,1,0)then put the measure into the visual filterThe output
Best Regards,
Yolo Zhu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.