Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
pdory
Frequent Visitor

Dax for YoY comparison with slicer

Hi all, 

 

I have a simple data model. It includes a fact table (Tickets) related to a date table (Calendar) based on the creation date of the ticket.

 

I want to measure the following:

  1. Count of tickets opened for a selected period on a slicer 
  2. The count of tickets opened for the same period minus 365 days
  3. Measure the percentage change between 1 & 2.

 

I'm struggling to write a Dax for measures 2 & 3 that will dynamically adjust based on the slicer selection (date). Being able to use a slicer to determine the time period is a must have, however I'm open to different options (single date slicer vs multiple date slicers). 

 

Is there any way to achieve this YoY comparison dynamically using slicer?

 

Thanks in advance.

 

Dax.jpg

 

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Assuming slicers have been created from the Calendar Table, try this measure

Measure = calculate([your measure],sameperiodlastyear(calendar[date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Assuming slicers have been created from the Calendar Table, try this measure

Measure = calculate([your measure],sameperiodlastyear(calendar[date]))

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Ughh I overcomplicated my Dax with a bunch of filters + used the wrong date columns. Should have known better. Thanks for the reply Ashish, sometimes I need to be reminded that simple can be better.

You are welcome.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

@pdory check this video on my YT channel: Explore SAMEPERIODLASTYEAR & PARALLELPERIOD Time Intelligence functions? Are they same? - Part 5 - Y...



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.

pdory
Frequent Visitor

Thanks for the reply and video. I just subscribed to your channel. 

 

Cheers!

Helpful resources

Announcements
PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.