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
Anonymous
Not applicable

Rolling 6 Month Count

Hello,

 

I want to calculate the Distinct Count for Rolling 6 months for the ORDER_NO

For example: If I'm looking at the current month, the Rolling 6Month Count should reflect the total count for the prior 6 months (not including the current month)

Here is what I tried but it does not give me the correct numbers.

 

Rolling 6M Count = CALCULATE(DISTINCTCOUNT(Table[ORDER_NO]),
DATESINPERIOD('Calendar'[Date], MAX(Table[TA1]), -6,MONTH ))
 
(I do have a Calendar Table which is linked  to TA1)
rolling 6.PNG

 

 

Any help on this much appreciated! Thank you.

1 ACCEPTED SOLUTION
PaulDBrown
Community Champion
Community Champion

@Anonymous 

How about:

 

 

 

Rolling 6M Count = CALCULATE(DISTINCTCOUNT(Table[ORDER_NO]),
DATESINPERIOD('Calendar'[Date], MAX('Calendar [Date]), -6,MONTH )) - DISTINCTCOUNT(Table[ORDER NO])

 

 

 

This should exclude the current month value. 

EDIT: Actually, depending on whether you wish to exclude the rolling last month, you might need:

 

Rolling 6M Count = CALCULATE(DISTINCTCOUNT(Table[ORDER_NO]),
DATESINPERIOD('Calendar'[Date], MAX('Calendar [Date]), -7,MONTH )) - CALCULATE(DISTINCTCOUNT(Table[ORDER NO]), DATESINPERIOD(Calendar'[Date], MAX('Calendar [Date]), -1,MONTH ))

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






View solution in original post

10 REPLIES 10
PaulDBrown
Community Champion
Community Champion

@Anonymous 

How about:

 

 

 

Rolling 6M Count = CALCULATE(DISTINCTCOUNT(Table[ORDER_NO]),
DATESINPERIOD('Calendar'[Date], MAX('Calendar [Date]), -6,MONTH )) - DISTINCTCOUNT(Table[ORDER NO])

 

 

 

This should exclude the current month value. 

EDIT: Actually, depending on whether you wish to exclude the rolling last month, you might need:

 

Rolling 6M Count = CALCULATE(DISTINCTCOUNT(Table[ORDER_NO]),
DATESINPERIOD('Calendar'[Date], MAX('Calendar [Date]), -7,MONTH )) - CALCULATE(DISTINCTCOUNT(Table[ORDER NO]), DATESINPERIOD(Calendar'[Date], MAX('Calendar [Date]), -1,MONTH ))

 





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

Thank you, Looks like this works! 

@Anonymous 

Great! Out of curiosity, which one are you using?





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






Anonymous
Not applicable

I'm using this 

Rolling 6M Count = CALCULATE(DISTINCTCOUNT(Table[ORDER_NO]),
DATESINPERIOD('Calendar'[Date], MAX('Calendar [Date]), -6,MONTH )) - DISTINCTCOUNT(Table[ORDER NO])

amitchandak
Super User
Super User

@Anonymous , try like

 

Rolling 6M Count = CALCULATE(DISTINCTCOUNT(Table[ORDER_NO]),
DATESINPERIOD('Calendar'[Date],eomonth( MAX(Table[TA1]),-1), -6,MONTH ))

 

Rolling 6M Count = CALCULATE(DISTINCTCOUNT(Table[ORDER_NO]),
DATESINPERIOD('Calendar'[Date],ENDOFMONTH( MAX(Table[TA1]),-1,month), -6,MONTH ))

Anonymous
Not applicable

Hi @amitchandak Thank you, but it didn't give me the results I'm looking for. 

 

I used the following

Rolling 6M Count = CALCULATE(DISTINCTCOUNT(Table[ORDER_NO]),
DATESINPERIOD('Calendar'[Date],eomonth( MAX(Table[TA1]),-1), -6,MONTH ))

 

The results I'm getting starts from Feb 19, My data starts from Jan 19 to current Date. 

The Rolling 6 Month count should start to show from the 6th month correct? 

For example, If I'm looking at July 19, It should show the total count of Orders from Jan 19 -Jun 19. 

 

Jan 19 -Jun 19 Should not have any results since there are no data for the previous 6 months data available. 

 

Thank you!

Anonymous
Not applicable

I have a different Measure which counts the order numbers for Rolling months.  which works great. Is there a way to use that Measure to calculate this 6 Month rolling?

 

Rolling 6M Count = CALCULATE([Rolling Pass Count]) ................?
 
Thanks 
pranit828
Community Champion
Community Champion

HI @Anonymous 

CALCULATE(DISTINCTCOUNT(Sales[Sales Amount]),DATESMTD(dateadd('Date'[Date],-6,MONTH)))




PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile

HI @Anonymous 

I tested it out, you could refer to below steps:

Create a calender table:

Table = CALENDARAUTO()

Create a measure:

DIVIDE(CALCULATE(DISTINCTCOUNT(Sales[Sales Amount]),DATESINPERIOD('Table'[Date],MAX('Sales'[Date]),-6,MONTH)),6)




PBI_SuperUser_Rank@1x.png


Hope it resolves your issue? 
Did I answer your question? Mark my post as a solution!

Appreciate your Kudos, Press the thumbs up button!!
Linkedin Profile
Anonymous
Not applicable

Thank you @pranit828  it did not work,  it gave me the count for the 6th month ago Order only. 

For example: for July the result was 6 (Jan only count), It should be Order numbers count from Jan -Jun) 

 

Thanks 

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.