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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
adrianPadurariu
Resolver I
Resolver I

rolling mtd of working days with slicer selection

Hello,

 

I am trying to have a measure that calculates the rolling sum of working days from the beginning of the month until the selected working day.

I have a Date table where I created:

weekday = WEEKDAY('Calendar'[Date],2)
Then I created the number of working days in the month:
# working days = IF( TOTALMTD(SUM('Calendar'[workday]),'Calendar'[Date]) = 0 , 1 , TOTALMTD(SUM('Calendar'[workday]),'Calendar'[Date]))
Fact table with the column TotalFacialValue
One slicer with Year/Month
One Slicer with # working days
 
I need to calculate rolling MTD from the begining of the selected Year/Month, until the selected # working days
adrianPadurariu_0-1695818952824.png

 

Example: If I will select # of working numbers = 10 with January/2022, the measure will calculate from 3rd of January( the first working day in the month), until 14th of January (the 10th working day)

adrianPadurariu_1-1695819230975.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @adrianPadurariu ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1695967735999.png

(2) We can create a table. Use the column of the new table as slicer.

SlicerTable = GENERATESERIES(1,35,1)

(3)We can create a measure.

Measure = 
var _a=CALCULATE(SUM('Fact table'[TotalFacialValue]),FILTER(ALLSELECTED('Calendar'),[# working days]<= SELECTEDVALUE('SlicerTable'[slicer working day]) && [# working days]=1 && 'Calendar'[WorkDay]<>0))
var _b=CALCULATE(SUM('Fact table'[TotalFacialValue]),FILTER(ALLSELECTED('Calendar'),[# working days]<= SELECTEDVALUE('SlicerTable'[slicer working day]) && [# working days]<>1 && [# working days]<>0))
return IF([# working days]=SELECTEDVALUE('SlicerTable'[slicer working day]),_a+_b,BLANK())

(4) Then the result is as follows.

vtangjiemsft_1-1695967900600.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

2 REPLIES 2
Anonymous
Not applicable

Hi @adrianPadurariu ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data. 

vtangjiemsft_0-1695967735999.png

(2) We can create a table. Use the column of the new table as slicer.

SlicerTable = GENERATESERIES(1,35,1)

(3)We can create a measure.

Measure = 
var _a=CALCULATE(SUM('Fact table'[TotalFacialValue]),FILTER(ALLSELECTED('Calendar'),[# working days]<= SELECTEDVALUE('SlicerTable'[slicer working day]) && [# working days]=1 && 'Calendar'[WorkDay]<>0))
var _b=CALCULATE(SUM('Fact table'[TotalFacialValue]),FILTER(ALLSELECTED('Calendar'),[# working days]<= SELECTEDVALUE('SlicerTable'[slicer working day]) && [# working days]<>1 && [# working days]<>0))
return IF([# working days]=SELECTEDVALUE('SlicerTable'[slicer working day]),_a+_b,BLANK())

(4) Then the result is as follows.

vtangjiemsft_1-1695967900600.png

 

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

Thank you, it's working.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors