The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
Hi there,
I'm facing some trouble here when trying to insert a filtering condition for a Running Total of cumulative sales.
Althought the running total without filter runs perfectly, when I try to put a filter into the sentence it stops showing a "growth" line and starts showing a line that goes up and down
My Running Total, one which is running perfectly is:
M Filtered Sales SUM running total over Date =
CALCULATE(
SUM('Sales'[Value]);
FILTER('Sales';'Sales'[Country]="Brazil");
FILTER( ALLSELECTED('Sales'); 'Sales'[Date] <= MAX ( 'Sales'[Date] ) ))
Can you help me ?
Solved! Go to Solution.
Try this measure instead. Filtering the whole Sales table is affected your filters more than you intended. Note that I changed your ALLSELECTED() part too. If this doesn't work, you can change it back to ALLSELECTED('Sales'). I don't know your model, so could be either way.
M Filtered Sales SUM running total over Date =
CALCULATE(
SUM('Sales'[Value]);
'Sales'[Country]="Brazil";
FILTER( ALLSELECTED('Sales'[Date]); 'Sales'[Date] <= MAX ( 'Sales'[Date] ) ))
If this solution works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
Hi @Anonymous ,
Is this problem solved?
Best Regards,
Icey
@Anonymous , Try like
CALCULATE(
SUM('Sales'[Value]);
FILTER( ALLSELECTED('Sales'); 'Sales'[Date] <= MAX ( 'Sales'[Date] ) && 'Sales'[Country]="Brazil"))
@Anonymous As a best practice, add date dimension in your model and use it for and time intelligence calculations. There are many posts on how to add date dimension and below is the link to a few. Once the date dimension is added, mark it as a date table on table tools.
https://www.sqlbi.com/articles/creating-a-simple-date-table-in-dax/
https://radacad.com/create-a-date-dimension-in-power-bi-in-4-steps-step-1-calendar-columns
Add following measure and it will work more efficient on large datasets
SUM('Sales'[Value]);
FILTER( ALLSELECTED('CalendarTable'[Date]); 'CalendarTable'[Date] <= MAX ( 'CalendarTable'[Date] ) ),
'Sales'[Country]="Brazil"
)
Let's try to follow the best practice for scalable solutions. I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos whoever helped to solve your problem. It is a token of appreciation!
Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!
Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo
If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤
Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.
Try this measure instead. Filtering the whole Sales table is affected your filters more than you intended. Note that I changed your ALLSELECTED() part too. If this doesn't work, you can change it back to ALLSELECTED('Sales'). I don't know your model, so could be either way.
M Filtered Sales SUM running total over Date =
CALCULATE(
SUM('Sales'[Value]);
'Sales'[Country]="Brazil";
FILTER( ALLSELECTED('Sales'[Date]); 'Sales'[Date] <= MAX ( 'Sales'[Date] ) ))
If this solution works for you, please mark it as the solution. Kudos are appreciated too. Please let me know if not.
Regards,
Pat
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.