Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I am having issues getting the right dax measure to find the cummulative total between two dates in the past. the tricky part is i need to go back a 6mth period and then get the total of the previous 6 months.
So to explain in example, in my file, the max month is April 2020. I need to get the sum for Oct 2019 (6 mths ago) thru May 2019 (12 mths ago).
I am using a date table. I want to take selected month and get the sum for the previous 6-12 mths. I tried the following but its just not working.
Did any of the replies answers your query? If it does, then please mark it as a solution.
If your problem is still unresolved, please share more details.
Cheers!
Vivek
If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂
https://www.vivran.in/
Connect on LinkedIn
Please try this approach instead. I've never actually tried this, but it just might work. I thought it might unintentionally include the mindate in the date range, so I filtered that out. Please let me know if it works. If not, there is always the brute force approach using DATE(Year( ), Month(), Day(), but that is less elegant.
If this works for you, please mark it as 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.
Hello @cwnoll
You may try the following link:
https://www.vivran.in/post/moving-average-using-dax
In this replace the average calculation with the sum.
Cheers!
Vivek
If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂
https://www.vivran.in/
Connect on LinkedIn
Vivek,
I tried out this measure and had to make one a small correction (removed Filter() part and adding "-1" to each mindate). Please see the updated measure below.
6-6 Gross Charges =
VAR mindate =
MIN ( 'Calendar'[Date] )
VAR prev12mos =
DATESINPERIOD ( 'Calendar'[Date], mindate-1, -12, MONTH )
VAR prev6mos =
DATESINPERIOD ( 'Calendar'[Date], mindate-1, -6, MONTH )
VAR prevprev6mos =
EXCEPT ( prev12mos, prev6mos )
RETURN
CALCULATE ( SUM ( 'ProjectX'[Gross Charges] ), prevprev6mos )
Also, don't worry about trying to use functions and do things you don't fully understand. Almost everyone in this community is sharing knowledge from all the mistakes they've made. Keep learning and trying new things.
If this works for you, please mark it as 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.
Thank you so much for the quick feedback, but this still didnt work. Maybe I can attempt to explain better.
My current month is April 2020, I need to find the SUM of the gross charges for May 2019 thru Oct 2019. The idea is April 2020 would skip previous 6 months, then get the sum of the previous 6 months to that.
Since current Month is April 2020, it would skip Mar2020,Feb2020,Jan2020,Dec2019,Nov2019,Sep2019, then sum Oct2019-May2019.
Does this help at all?
Try this:
Previous Six Month =
VAR _CurrentMonth =
MAX ( dtCalendar[Date] )
VAR _StartMonth =
EDATE ( [CurrentMonth], -12 ) + 1
VAR _Filter =
DATESINPERIOD ( dtCalendar[Date], _StartMonth, 6, MONTH )
VAR _Sum =
IF (
_StartMonth >= FIRSTDATE ( ALLSELECTED ( dtCalendar[Date] ) ),
CALCULATE ( SUMX ( dtCalendar, [Total Sales] ), _Filter )
)
RETURN
_Sum
Cheers!
Vivek
If it helps, please mark it as a solution
Kudos would be a cherry on the top 🙂
https://www.vivran.in/
Connect on LinkedIn
What result did you see with my latest expression? I was pretty sure that would do it. Are you using the Month column from your Calendar table in your visual? Can you say more about your model?
If this works for you, please mark it as 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.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
11 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
14 | |
12 | |
11 | |
10 | |
9 |