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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
abc_777
Super User
Super User

dynamic days

Dear Concern,

 

I have total sales and calendar table

 

I can do previous month sale or last 30 days sale

 

but these are static values

I need dynamic date value. mean user can put last any number of days and it will show those days sale

 

Example: if user give last 10 or 12 or 18 days it will show previous sales of 10 or 12 or 15 days

 

Means user can choose to give previosus any number of days to see sale in that time frame

 

thanks

2 ACCEPTED SOLUTIONS
amitchandak
Super User
Super User

@abc_777 , You can use what of parameter for that

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

 

 

example

 Rolling N day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max('Date'[Date]),-1* selectedvalue(whatif[value]) ,Day)) 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

Anonymous
Not applicable

Hi @abc_777 

Please correct me if I wrongly understood your question.

Take 'Calendar Date'[Date] as the standard, and then calculate the date of the previous few days . I've taken the previous three days as an example .

Sum last 3 days = CALCULATE(SUM('Table'[sales]),FILTER('Table','Table'[Date]>CALCULATE(MAX('Calendar Date'[Date])-3) && 'Table'[Date]<=MAX('Calendar Date'[Date])))

 

Original data :

Ailsa-msft_0-1619399957659.png

The effect is as shown:

Ailsa-msft_1-1619399957662.png

 

Best Regards

Community Support Team _ Ailsa Tao

 

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

6 REPLIES 6
Anonymous
Not applicable

Hi @abc_777 

Please correct me if I wrongly understood your question.

Take 'Calendar Date'[Date] as the standard, and then calculate the date of the previous few days . I've taken the previous three days as an example .

Sum last 3 days = CALCULATE(SUM('Table'[sales]),FILTER('Table','Table'[Date]>CALCULATE(MAX('Calendar Date'[Date])-3) && 'Table'[Date]<=MAX('Calendar Date'[Date])))

 

Original data :

Ailsa-msft_0-1619399957659.png

The effect is as shown:

Ailsa-msft_1-1619399957662.png

 

Best Regards

Community Support Team _ Ailsa Tao

 

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

amitchandak
Super User
Super User

@abc_777 , You can use what of parameter for that

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

 

 

example

 Rolling N day = CALCULATE(sum(Sales[Sales Amount]),DATESINPERIOD('Date'[Date],max('Date'[Date]),-1* selectedvalue(whatif[value]) ,Day)) 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi,

Thanks for your nice solution

 

I have done followings

 

Rolling X day = CALCULATE(sum('bm_all_cul bm_sales_dhk_all_cul'[Actual Quantity]), -------- Quantity of product
DATESINPERIOD(BMCalendar[Date],MAX(BMCalendar[Date]),-------------- global calendat date
-1 * SELECTEDVALUE('How Many days Back'[How Many days Back]) , Day))------------what is parameter
 
1.JPG
 
when i give 5 then may 2021 increases to 5 more day or if I give 10 then may 9th which is not yet to come.
I need to filter activated and show last 10 days or 12 days from today mean today is 23rd april 2021 so should remove all dates and
show me only quantity data from 13th april 2021
 
you help really appriciable.
 
thanks
 
 
 
 

@amitchandak,

I did some calculation from -365 to +365 I dont know is it ok or not but when I give +30 its show till end of april data but today is 23rd when i give -10 days its cumulatively goes back one by one but still showing whole April 23 days. not just back 10 days.1.JPG

 

I want to see last 10 days total quantity

 

appriciate you help

@amitchandak 

I am soo sorry to give you several messages.

 

I think its working. when I give -20 it shows me previous 20 days but I want some more clear table. you you see at my last message you will see -20 is working but then before that -20 it shows some annonimus calculations. is there any ways i can clean them.

 

when i increase -20 to -25 then newly 5 more column add in report and so on so on

I hope you understand

thanks

1.JPG

 

How can I clean red tick mark portion and when I give data like -13 days or -15 days then they will come accodringly my needs

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors