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
Sunshine123
Frequent Visitor

How to get the sum between two dates

Hello, 

I want to create a DAX or a column in order to get the sum between the date and minus 365 days. 

I have created three tables: 

1) Data Table

2) Sales Table 

3) Order in hand Table

I want to get the sum from the sales table for each row in the order in hand table. Therefore I have provided the start date (date Minus 365) and the end date (Date) 

I have tried serveral options like datesinperiod/datesbetween. 

15.06.png

Any suggestions? 

Kind Regards! 

  

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Hi  @Sunshine123 ,

I created some data:

Order in hand Table:

vyangliumsft_0-1655715239542.png

Here are the steps you can follow:

1. Create measure.

Measure =
var _mindate=
MINX(FILTER(ALL('Sales Table'),'Sales Table'[Date Minus 365]>=MAX('Order in hand Table'[Date])),[Date Minus 365])
return
CALCULATE(
    SUM('Sales Table'[Sales]),FILTER(ALL('Sales Table'),'Sales Table'[Date Minus 365]=_mindate))

2. Result:

vyangliumsft_1-1655715239546.png

If I have misunderstood your meaning, please provide your desired output and your pbix without privacy information, or Order in hand Table data.

 

Best Regards,

Liu Yang

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

1 REPLY 1
v-yangliu-msft
Community Support
Community Support

Hi  @Sunshine123 ,

I created some data:

Order in hand Table:

vyangliumsft_0-1655715239542.png

Here are the steps you can follow:

1. Create measure.

Measure =
var _mindate=
MINX(FILTER(ALL('Sales Table'),'Sales Table'[Date Minus 365]>=MAX('Order in hand Table'[Date])),[Date Minus 365])
return
CALCULATE(
    SUM('Sales Table'[Sales]),FILTER(ALL('Sales Table'),'Sales Table'[Date Minus 365]=_mindate))

2. Result:

vyangliumsft_1-1655715239546.png

If I have misunderstood your meaning, please provide your desired output and your pbix without privacy information, or Order in hand Table data.

 

Best Regards,

Liu Yang

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

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.