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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
User1
New Member

SUMIFs with date range conditionals

Hi all,

I have a table, with columns showing the numbers I want to add up, and columns containing date between which I would not want to add them up.

For example:

Number      Date from       Date to

5                       13/4                   15/4

10                    14/4                    20/4

5                        22/4                    25/4

 

I want to create a second table with a daily tally of the total of the "Number" column, but onkly if the date in question is outside the "Date from - date to" range. Either as a conditional column, or as a measure. For example:

Day               TOTAL

11/4              20

12/4              20

13/4               15

14/4                5

etc.

 

I tried to use the CALCULATE  ( SUM(), FILTER()) functionality, but could not get it to work. Is that the right approach? Or is there a better way to do this?

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

Hi @User1 ,

 

Please create a new date table firstly. And there is not a relationship between the tables.

Example:

Date = CALENDAR(DATE(2020,4,1),DATE(2020,5,1))

 

Then create a measure like this:

Measure =
CALCULATE (
    SUM ( 'Table'[Number] ),
    FILTER (
        'Table',
        MAX ( 'Date'[Date] ) < 'Table'[Date From]
            || MAX ( 'Date'[Date] ) > 'Table'[Date To]
    )
)

7.PNG

 

For more details, please see the attachment.

 

 

Best Regards,
Xue Ding
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

3 REPLIES 3
v-xuding-msft
Community Support
Community Support

Hi @User1 ,

 

Please create a new date table firstly. And there is not a relationship between the tables.

Example:

Date = CALENDAR(DATE(2020,4,1),DATE(2020,5,1))

 

Then create a measure like this:

Measure =
CALCULATE (
    SUM ( 'Table'[Number] ),
    FILTER (
        'Table',
        MAX ( 'Date'[Date] ) < 'Table'[Date From]
            || MAX ( 'Date'[Date] ) > 'Table'[Date To]
    )
)

7.PNG

 

For more details, please see the attachment.

 

 

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

Thanks, in the end I got it to work, but I had to use the OR() statement instead of the || (which I assume does the same)?
Thanks anyways 🙂 

amitchandak
Super User
Super User

@User1 , there is a similar problem solved in the file attached after the signature. If that can help

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

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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
Top Kudoed Authors