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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
stribor45
Post Prodigy
Post Prodigy

Count for the same period of last year based on slicer current selection

I have a measure that looks like this...

 

CUSTOMER_COUNT = COUNTX(FILTER('Table#1','Table#1'[Type] = "Evening"),'Table#1'[ID])

I also have a calendar table so when I drag the visual (table) to Canvas and drag the dates column from Calendar and CUSTOMER_COUNT I get the correct count based on the slicer  values(which uses the same Calendar table)

 

So if the slicer is currently selected to show count for values between April 1 - April 30 2023 how can I write DAX for the same period last year, April 1- April 30 2022 using this same measure? If slicer is currently selected for Jan 1, 2023 - March 31 2023 how can I count for Jan 1 2022 - March 31 2022

 

1 ACCEPTED SOLUTION

@stribor45 Well, the errors would indicate that you have duplicate dates in your Calendar table, which doesn't make much sense as that is generally not the case. Again, just another reason to avoid DAX TI functions in my opinion. I don't use them, they are all just FILTER functions for the most part.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

6 REPLIES 6
stribor45
Post Prodigy
Post Prodigy

Wierd after all these attempts and trying different things it finally worked when I used the "vertical list" slicer. When I had the slicer set as "between" it didn't work at all.

stribor45
Post Prodigy
Post Prodigy

I can see what the problem is. Dates have to be unique.  My current calendar table needs to look like the above but I can create another table with unique dates and create a relationship  to the Calendar table

stribor45
Post Prodigy
Post Prodigy

this is what my calendar table looks like. its increasing by 1 minute

 

stribor45_0-1694363876747.png

 

Greg_Deckler
Super User
Super User

@stribor45 You may find this helpful - https://community.powerbi.com/t5/Community-Blog/To-bleep-With-Time-Intelligence/ba-p/1260000

Also, see if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler  thank you for providing this. much appreciated. I am confused about why I am receiving error that I have duplicate dates in my calendar table. I dont have any duplicates at all and not sire why it is giving me the error.  See this screenshot and hope you can assist me

 

Capture.PNG

@stribor45 Well, the errors would indicate that you have duplicate dates in your Calendar table, which doesn't make much sense as that is generally not the case. Again, just another reason to avoid DAX TI functions in my opinion. I don't use them, they are all just FILTER functions for the most part.



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Power BI Cookbook Third Edition (Color)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.