Reply
gauri
Helper III
Helper III
Partially syndicated - Outbound

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

Syndicated - Outbound

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

Syndicated - Outbound

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.

Syndicated - Outbound

@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

Syndicated - Outbound

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

Syndicated - Outbound

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

Syndicated - Outbound

@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))

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Syndicated - Outbound

@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

avatar user

Helpful resources

Announcements
FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

March2025 Carousel

Fabric Community Update - March 2025

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

Top Solution Authors (Last Month)
Top Kudoed Authors (Last Month)