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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. 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

Share with Power BI Enthusiasts: 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
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.