Forum Discussion
Using Measure to Compare Current Period to Previous Period
- Anonymous5 years ago
Hi Everyone,
Here is the solution that I have found to work. I hope someone finds this useful. I will give credit to the freelancer who came up with this at the end of the post.
End Result:
You will have one slicer for the current period and one slicer for the previous period. You can compare any range of dates to one another by selecting your date range in the corresponding slicer. In the photo below the current period slicer is showing 6/1/2021-6/30/2021 and the previous period slicer is showing 5/1/2021-5/31/2021. The light blue line is showing the current period and the dark blue line is showing the previous period in the visuals.Step 1:
Create a new measure called "Previous Date Selector" and use your date table as the parameter value.
Step 2:
Create an inactive one too many relationship between your "Previous Date Selector" and regular date table.
Step 3:
Create a slicer from your standard date table and name it "current period" and create a slicer from your "previous date selector" and name it "previous period."
Step 4:
Create a measure with the following dax. In this case, I am comparing total sessions in the current period to total sessions in the previous period so I am using the "total sessions" value.
Step 5
Add your two values to the visual you would like to use to compare the current period to the previous period. In this case, I am comparing total sessions from google analytics so I have a measure for "total sessions", which is synched to the current period slicer and a measure for "total visitors for previous period", which is synched to the previous period slicer.
I hope this helps someone!
Freelancer: andystepas | Profile | Fiverr
Anonymous I think you are over-engineering the problem. There are way too many solution available to achieve MoM/QoQ/YoY based on the slicer selection, like calculation groups or you can use Row Based time intelligence by following this blog post Row-based Time Intelligence - Phil Seamark on DAX
✨ Follow us on LinkedIn
Check my latest blog post The Power of Using Calculation Groups with Inactive Relationships (Part 1) (perytus.com) I would ❤ Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!
⚡ Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.⚡
- Anonymous5 years agoNot applicable
Hi parry2k ,
I have considered creating measures for a monthly, quarterly, and yearly comparison, but the problem I foresee with this method is when management says they want to see a quarterly comparison instead of a monthly comparison, all the measures will have to be switched out on the visual to show the new time comparison. I would like to have the ability to specify a date range and then show the previous period for that specific date range. This will make the entire report dynamic and eliminate the need for a measure for each time range. The measure above works almost perfectly, but the current period and previous period are compared by days, so if there are 30 days in one month and 31 days in another month, one of the months will either be missing a day or have an extra day. I am wondering if you have a suggestion on how to turn this measure into a monthly comparison. - Anonymous5 years agoNot applicable
Hi parry2k,
What do you think about the solution above?
If you think it can be useful please consider accepting it as a solution.Thank you,
Joshua Cortigiano