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
gauri
Helper III
Helper III

How to get previous cummulative count for rolling 30 days

Hello,

In the image below i have rolling 30 days visual in which, in the column values i have count of last 30 days, this means i had 42 residents on 6th of may  and 48 residents on 21st may and so on. Here i want to calculate change between rolling 30 days count and its previous count. for eg: on 5th may 2020 i have a count of 43 and its previous day count i.e on 4th may 2020 is 42 , so my change would be 43-42 i.e 1 which which would be displayed in the line values. This will be applied for every value. Here 30th day is 3rd may 2020 so it should fetch previous day and its count.

 

rolling 30 days.PNG

 

to calculate this daily count i have used these following measure :

 

Average daily count = AVERAGEX(VALUES(census_pcc_new[CensusDate]), [row count])
 
census client count last 30 days =
var last_day = TODAY()
return
CALCULATE([Average daily count],
FILTER(census_pcc_new, census_pcc_new[CensusDate] > last_day- 30 && census_pcc_new[CensusDate] <= last_day ),FILTER(census_pcc_new, census_pcc_new[FacilityID]))
 
How can i get previous count and calculate the change.
 
Thanks
7 REPLIES 7
gauri
Helper III
Helper III

It would be great if anyone helps me out with this issue, as it is very urgent.

 

Thanks,

v-diye-msft
Community Support
Community Support

Hi @gauri 

 

you might consider creating pbix file that will contain some sample data (remove the confidential info), upload the pbix to onedrive for business and share the link to the file. Please do not forget to describe the expected results based on this sample data.

 

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

@v-diye-msft There are measures present in the visual , nad creating a sample pbix would take time and this issue is really urgent, so it will not be possible to send a pbix . Other than this i can provide information by using we can solve this issue

Tahreem24
Super User
Super User

Hi @gauri ,

Try the below DAX:

Subtraction Measure=
VAR last_30day = CALCULATE([Average daily count],
FILTER(census_pcc_new, census_pcc_new[CensusDate] > TODAY()- 30 && census_pcc_new[CensusDate] <= TODAY() ),FILTER(census_pcc_new, census_pcc_new[FacilityID]))
 
VAR last_31days = 
CALCULATE([Average daily count],
FILTER(census_pcc_new, census_pcc_new[CensusDate] > TODAY()- 31 && census_pcc_new[CensusDate] <= TODAY() ),FILTER(census_pcc_new, census_pcc_new[FacilityID]))
 
RETURN  last_30day- last_31day
 
 
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Hi @Tahreem24 

i tried your  measure. its giving me output like this :

 

rolling 30 days new.PNG

 

here everywhere its showing 0 , so places where 30 days count is 43 and its previous count is 42 it should give me 1, and in this visual, census change is the subtraction measure which you had sent me.

amitchandak
Super User
Super User

@gauri , try like

Rolling 30 day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX(Sales[Sales Date]),-30,Day))

Rolling 30 day 1 day before = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],MAX(Sales[Sales Date])-1,-31,Day))

@amitchandak 

 

i tried the above measure but i am not able to get a proper count of previous day and also all the counts are not displaying for today -30 days which were first displaying in the visual.

image rolling 30 days.png

 

4th may 2020 should take previous value as 41 , its taking 42

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.