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
alsolok
Helper I
Helper I

Dateinperiod with -1 month, -6 month, -12 month

Hello everyone,

I have the problem with this measures.

I went to calculate the distinct count customers with period interval for 1 month:

Nbre customers validation < 1 month:= CALCULATE(distinctcount('Customers'[id_client]), 'Customers'[id_principal] = BLANK(), FILTER('Customers','Customers'[Nbre_valid]>0), DATESINPERIOD(
'Customers'[date_photo],
MAX('Customers'[date_photo]),
-1,
MONTH
))

 

For 6 month

 

Nbre customers validation < 1 month:= CALCULATE(distinctcount('Customers'[id_client]), 'Customers'[id_principal] = BLANK(), FILTER('Customers','Customers'[Nbre_valid]>0), DATESINPERIOD(
'Customers'[date_photo],
MAX('Customers'[date_photo]),
-6,
MONTH
))

 

For 12 month

 

Nbre customers validation < 1 month:= CALCULATE(distinctcount('Customers'[id_client]), 'Customers'[id_principal] = BLANK(), FILTER('Customers','Customers'[Nbre_valid]>0), DATESINPERIOD(
'Customers'[date_photo],
MAX('Customers'[date_photo]),
-12,
MONTH
))

 

Customers[date_photo] is the column the table fact is the relation with dimension table Date.

The Dim Table Date is the filter in the segment(power bi) not interaction with the measures -1, 6 and 24 month

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@alsolok , You need to create a date table table first and join with you Table table

 

 

Create these measures

M1= CALCULATE(distinctcount('Customers'[id_client]), 'Customers'[id_principal] = BLANK(), FILTER('Customers','Customers'[Nbre_valid]>0) )

 

then

 

Rolling 12 = CALCULATE([M1],DATESINPERIOD('Date'[Date ],MAX(Date[Date]),-12,MONTH))

 

Rolling 6 = CALCULATE([M1],DATESINPERIOD('Date'[Date ],MAX(Date[Date]),-6,MONTH))

 

or you can use date from you table as max

 

Rolling 12 = CALCULATE([M1],DATESINPERIOD('Date'[Date ],MAX('Customers'[date_photo]),-12,MONTH))

 

Rolling 6 = CALCULATE([M1],DATESINPERIOD('Date'[Date ],MAX('Customers'[date_photo]),-6,MONTH))

 

 

You can use what if to have dynamic number 1, 6, 12 etc

 

Rolling Months Formula: https://youtu.be/GS5O4G81fww

 

https://docs.microsoft.com/en-us/power-bi/desktop-what-if

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@alsolok , You need to create a date table table first and join with you Table table

 

 

Create these measures

M1= CALCULATE(distinctcount('Customers'[id_client]), 'Customers'[id_principal] = BLANK(), FILTER('Customers','Customers'[Nbre_valid]>0) )

 

then

 

Rolling 12 = CALCULATE([M1],DATESINPERIOD('Date'[Date ],MAX(Date[Date]),-12,MONTH))

 

Rolling 6 = CALCULATE([M1],DATESINPERIOD('Date'[Date ],MAX(Date[Date]),-6,MONTH))

 

or you can use date from you table as max

 

Rolling 12 = CALCULATE([M1],DATESINPERIOD('Date'[Date ],MAX('Customers'[date_photo]),-12,MONTH))

 

Rolling 6 = CALCULATE([M1],DATESINPERIOD('Date'[Date ],MAX('Customers'[date_photo]),-6,MONTH))

 

 

You can use what if to have dynamic number 1, 6, 12 etc

 

Rolling Months Formula: https://youtu.be/GS5O4G81fww

 

https://docs.microsoft.com/en-us/power-bi/desktop-what-if

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.