Check your eligibility for this 50% exam voucher offer and join us for free live learning sessions to get prepared for Exam DP-700.
Get StartedDon't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.
Hello all,
After googling for two pages, I'm struggling to find a simple way to create a cumulative sum measure by date and item in Power
BI (using DAX). I have a table which contains:
I have managed to obtain the cumulative sum by using the following expression (extracted from DAXPatterns):
CALCULATE ( SUM ( Table[Requests] ), FILTER ( ALL ( 'Date'[Date] ), 'Date'[Date] <= MAX ( 'Date'[Date] ) ) )
But I would like to obtain a measure indicating how many requests have been made by a user up to a certain date.
Is there a simple way to do this?.
Thank you very much for your help.
Any visualization that you are using should be giving you an implicit filter on user and should break down the measure as needed. Try a table or matrix or column/bar chart (for the latter, with date as the the X-axis and user as the category).
Hope this helps
David
When you say "up to a certain date" do you mean that that date would be chosen by a user (i.e. a slicer) and the cumulative total will reflect this chosen date?
So the ALL() argument in the FILTER() argument makes your measure ignore any slicers/filtering, so try removing that and see if it works.
I think I may have not explained myself very well. I would like to have a cumulative sum taking into consideration date and username.
I have found in StackOverflow a working solution in SQL (http://stackoverflow.com/questions/17971988/sql-server-cumulative-sum-by-group😞
select dummy_id, date_registered, item_id, quantity, price, (select sum(quantity) from t t2 where t2.item_id = t.item_id and t2.date_registered <= t.date_registered ) as cumulative from table t;
Is there any way to translate this to DAX? Unfortunately, I think this problem exceedes my set of skills (I'm a beginner in DAX/Power BI)
Thank you very much.
So I recommend starting off with a table or matrix visual, putting username and date for the rows (in that order) and your cumulative sum measure as the value. This will give you, for each username, the running total for your dates. Then, add a slicer for date, and make sure your cumulative total matrix filters appropriately using the slicer. Finally, if all works fine, you can remove the dates field from your matrix and just use the slicer. The matrix (or any other visualization where username is an axis or legend) will show the cumulative total for each username up to the date selected by the slicer.
With all that said, there may need to be some tweaks to the measure, as I mentioned before, so that the ALL argument doesn't override the slicer. If you have some sample data we can give better guidance.
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.
Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.
User | Count |
---|---|
143 | |
85 | |
66 | |
51 | |
45 |
User | Count |
---|---|
217 | |
89 | |
82 | |
66 | |
57 |