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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

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

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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