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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Calculate with a date range?

Hello, 

 

I am trying to replicate what a "SUMIFS" forumla would do in excel with a date range. I have 2 main data tables one that has actual promoted sales units and one that has planned promoted sales units by promotion program based on a start date and end date.

 

I have relationships set up to a date table for both of them as well as a product table (by UPC). 

 

I would like to calculate the actual sales units for the time period between start and end date in the planned sales units table. 

 

I tried writing this formula but it's not working:  

CALCULATE([Promo Units CY],FILTER('Trade Plan 2019','Trade Plan 2019'[Start Date])>'Date'[Date],FILTER('Trade Plan 2019','Trade Plan 2019'[End Date])<'Date'[Date])
 
Actual Promoted SAles Units Table:
YearQuarterMonthDayGeographyPromo Units CYUPC
2019Qtr 1January27Ahold Delhaize Giant Carlisle Division-RMA - Food41000
2019Qtr 1February3Ahold Delhaize Giant Carlisle Division-RMA - Food6261001
2019Qtr 1February3Ahold Delhaize Giant Carlisle Division-RMA - Food8021002
2019Qtr 1February3Ahold Delhaize Giant Carlisle Division-RMA - Food6401003
2019Qtr 1February10Ahold Delhaize Giant Carlisle Division-RMA - Food6441001
2019Qtr 1February10Ahold Delhaize Giant Carlisle Division-RMA - Food7501002
2019Qtr 1February10Ahold Delhaize Giant Carlisle Division-RMA - Food5761003

 

Trade Plan 2019: planned promoted sales units by promotion program

 

Start DateEnd DatePromo EventGeographyPlanned Promo Units CYUPC
1/1/201902/30/2019Ahold Q1 PromoAhold Delhaize Giant Carlisle Division-RMA - Food1001000
1/2/201902/30/2020Ahold Q1 PromoAhold Delhaize Giant Carlisle Division-RMA - Food2001001
1/3/201902/30/2021Ahold Q1 PromoAhold Delhaize Giant Carlisle Division-RMA - Food1001002
1/4/201902/30/2022Ahold Q1 PromoAhold Delhaize Giant Carlisle Division-RMA - Food2501003
1/5/201902/30/2023Ahold Q1 PromoAhold Delhaize Giant Carlisle Division-RMA - Food3001001
1/6/201902/30/2024Ahold Q1 PromoAhold Delhaize Giant Carlisle Division-RMA - Food4001002
1/7/201902/30/2025Ahold Q1 PromoAhold Delhaize Giant Carlisle Division-RMA - Food2501003
1 ACCEPTED SOLUTION
Anonymous
Not applicable

I solved this with a "Datesbetween" formula

 

Actual Promo Units = CALCULATE([Promo Units CY], DATESBETWEEN('Date'[Date],MAX('Trade Plan 2019'[Start Date]),max('Trade Plan 2019'[End Date])))

View solution in original post

3 REPLIES 3
v-yuta-msft
Community Support
Community Support

@Anonymous ,

 

You can modify your measure as below:

result =
CALCULATE (
    [Promo Units CY],
    FILTER (
        'Trade Plan 2019',
        'Trade Plan 2019'[Start Date] > RELATED ( 'Date'[Date] )
            && 'Trade Plan 2019'[End Date] < RELATED ( 'Date'[Date] )
    )
)

Community Support Team _ Jimmy Tao

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

Anonymous
Not applicable

@v-yuta-msft  the formula didn't bring in any values - it's all blank

Anonymous
Not applicable

I solved this with a "Datesbetween" formula

 

Actual Promo Units = CALCULATE([Promo Units CY], DATESBETWEEN('Date'[Date],MAX('Trade Plan 2019'[Start Date]),max('Trade Plan 2019'[End Date])))

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.