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 there is no concept of almost perfectly, it is working or not, you have to use calculation group, maybe with 4 calculation items:
MoM
QoQ
YoQ
Custom
The top 3 are self-explanatory, and in the 4th one, use the range from date slicer and then do the comparison for the same period as you are doing now.
There are TONS of solutions around this and what I suggested above, I have used more than 100 times, not sure if you can take it from here or not.
✨ 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.⚡
Hi parry2k ,
I am not opposed to using those time intelligence calculations, but the DAX expression that I have posted provides more flexibility because you can compare any period to the exact same time range over the previous period by adjusting the slicer. It is very convenient and very useful for reports that need to be regularly changed to compare unique time periods. I have illustrated the issue that is still persisting below. You will see that the previous period is showing 5/1/2021 - 5/30/2021, but it should show 5/1/2021-5/31/2021. I am still wondering if there's a way to modify this formula so the previous period shows the entire month, instead of just showing the number of days that are in the current period.