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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Sales amount between n days and current date

Alright everyone, I believe I'm close on this one because it works, but only on the days I refresh the data (currently a once per month report). The DAX I used is here (60 and 90 day are calculated with the same statement, only the day number changed): 

 
Sales Last 30 =
CALCULATE(SUM(Table_1046[Extended Price]),
DATESINPERIOD(Table_1046[Invoice Date], TODAY(), -30, DAY)
)
 

Here is the screenshot of it functioning

 

 sales n days working.JPG

Here is a screenshot of it any day other than the updated day

sales n days not working.JPG

 

Greatly appreciate any help to finish this up. Thanks!

1 ACCEPTED SOLUTION
v-yulgu-msft
Employee
Employee

Hi @Anonymous ,

 

I would suggest you generate a date dimension table ('DateDim') with CALENDAR function. Establish a one to many relationship from 'DateDim' to Table_1046 based on date field.

 

Modify the measure formula as:

Sales Last 30 =
CALCULATE(SUM(Table_1046[Extended Price]),
DATESINPERIOD(DateDim[Date], TODAY(), -30, DAY)
)
Regards,
Yuliana Gu
Community Support Team _ Yuliana Gu
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
v-yulgu-msft
Employee
Employee

Hi @Anonymous ,

 

I would suggest you generate a date dimension table ('DateDim') with CALENDAR function. Establish a one to many relationship from 'DateDim' to Table_1046 based on date field.

 

Modify the measure formula as:

Sales Last 30 =
CALCULATE(SUM(Table_1046[Extended Price]),
DATESINPERIOD(DateDim[Date], TODAY(), -30, DAY)
)
Regards,
Yuliana Gu
Community Support Team _ Yuliana Gu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

This worked and I got to learn something new. Thanks for your help!!

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.