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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
obriaincian
Resolver I
Resolver I

Count number of changes to a date over last 3 months

Hi All,

 

Here's a sample of the data what I have. What I want to do is count the number of date changes to a SKU for the past 3 months only.

DateSKUExpiry Date
Dec-21PPPT-0125/01/2024
Dec-21WEC-5405/06/2023
Dec-21ERRE-6623/08/2025
Jan-22PPPT-0101/01/2024
Jan-22WEC-5405/06/2023
Jan-22ERRE-6623/08/2025
Feb-22PPPT-0101/01/2024
Feb-22WEC-5415/06/2023
Feb-22ERRE-6623/08/2025
Mar-22PPPT-0125/01/2024
Mar-22WEC-5415/06/2023
Mar-22ERRE-6623/08/2025

 

I'd like to output the results in a matrix that might look like the following:

 

SKUNumber of date changes
PPPT-011
WEC-542
ERRE-660

 

 

1 ACCEPTED SOLUTION

Hi @obriaincian ,

 

Please modify the measure like below:

Measure = CALCULATE(DISTINCTCOUNT('Table'[Date]),ALLEXCEPT('Table','Table'[SKU]),DATESINPERIOD('Table'[Date],MAX('Table'[Date]),-3,MONTH))-1

Vlianlmsft_0-1647937284258.png

 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
amitchandak
Super User
Super User

@obriaincian , try a measure like, Make sure you have date or create date using month year

 

Rolling 3 = CALCULATE(distinctcount(Table[Expiry Date]) ,DATESINPERIOD('Date'[Date ],MAX('Date'[Date ]),-3,MONTH))

 

 

refer if needed

Rolling Days Formula: https://youtu.be/cJVj5nhkKBw

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you @amitchandak ,

Unfortunately this doesn't work with the Date being in mmm-yy format. It is returning the last 3 months but it is not taking the year into account. 

e.g. it is returning Jan 22 and Jan 21 when used on my actual dataset.

@amitchandak would you please be able to give me some advice on the above with regards to taking the year into account?

Hi @obriaincian ,

 

Try to ceate a measure like below:

Measure = CALCULATE(DISTINCTCOUNT('Table'[Date]),ALLEXCEPT('Table','Table'[SKU]),DATESINPERIOD('Table'[Date],TODAY(),-3,MONTH))

Vlianlmsft_0-1646984092294.png


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

hi @V-lianl-msft thank you for your response. However it isn't a solution.

 

I may not have explained myself clearly. What I need to do is filter the "Date" column for all rows where date is within the last 3 months i.e. Jan-21, Feb-21,Mar-21.

 

Once I have that done I need to then check how many changes occured in the "Expiry Date" column for each SKU? 

 

Hope that makes sense?

Hi @obriaincian ,

 

Please modify the measure like below:

Measure = CALCULATE(DISTINCTCOUNT('Table'[Date]),ALLEXCEPT('Table','Table'[SKU]),DATESINPERIOD('Table'[Date],MAX('Table'[Date]),-3,MONTH))-1

Vlianlmsft_0-1647937284258.png

 


Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

obriaincian
Resolver I
Resolver I

For some reason the tables above are not formatting correctly.

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! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.