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

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

Reply
Anonymous
Not applicable

Date Range

Hi,

 

I have a formula but I am looking at changing it do the date range is specifically between two dates?

 

2017 YTD  = (IF (CALCULATE (SUM('Data Dump - Spend'[Credit (incl VAT)])) = BLANK(),0,

CALCULATE (SUM('Data Dump - Spend'[Credit (incl VAT)]),FILTER (ALL('Data Dump - Trade Spend'[Invoice Date] ),'Data Dump - Spend'[Invoice Date] <= DATE ( 2017, 6, 1 )))))

 

How could I change it to be between 01.04.2017 and 01.06.2017?

 

Kind regards

 

Dom

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

@Anonymous,

You can use this:

2017 YTD =
 (
    IF (
        CALCULATE ( SUM ( 'Data Dump - Spend'[Credit (incl VAT)] ) ) = BLANK (),
        0,
        CALCULATE (
            SUM ( 'Data Dump - Spend'[Credit (incl VAT)] ),
            FILTER (
                ALL ( 'Data Dump - Trade Spend'[Invoice Date] ),
                'Data Dump - Spend'[Invoice Date] <= DATE ( 2017, 6, 1 )
                    && 'Data Dump - Spend'[Invoice Date] >= DATE ( 2017, 4, 1 )
            )
        )
    )
)

View solution in original post

Anonymous
Not applicable

@Anonymous,

Try this instead: 

2017 YTD =
IF (
    CALCULATE ( SUM ( 'Data Dump - Spend'[Credit (incl VAT)] ) ) = BLANK (),
    0,
    CALCULATE (
        SUM ( 'Data Dump - Spend'[Credit (incl VAT)] ),
        FILTER (
            ALL ( 'Data Dump - Trade Spend'[Invoice Date] ),
            'Data Dump - Spend'[Invoice Date] <= DATE ( 2017, 6, 1 )
                && 'Data Dump - Spend'[Invoice Date] >= DATE ( 2017, 4, 1 )
        )
    )
        + 0
)

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

@Anonymous,

You can use this:

2017 YTD =
 (
    IF (
        CALCULATE ( SUM ( 'Data Dump - Spend'[Credit (incl VAT)] ) ) = BLANK (),
        0,
        CALCULATE (
            SUM ( 'Data Dump - Spend'[Credit (incl VAT)] ),
            FILTER (
                ALL ( 'Data Dump - Trade Spend'[Invoice Date] ),
                'Data Dump - Spend'[Invoice Date] <= DATE ( 2017, 6, 1 )
                    && 'Data Dump - Spend'[Invoice Date] >= DATE ( 2017, 4, 1 )
            )
        )
    )
)
Anonymous
Not applicable

Thanks, this works really well.

Anonymous
Not applicable

@Anonymous Although the empty value now shows up as blank instead of £0?

Anonymous
Not applicable

@Anonymous,

Try this instead: 

2017 YTD =
IF (
    CALCULATE ( SUM ( 'Data Dump - Spend'[Credit (incl VAT)] ) ) = BLANK (),
    0,
    CALCULATE (
        SUM ( 'Data Dump - Spend'[Credit (incl VAT)] ),
        FILTER (
            ALL ( 'Data Dump - Trade Spend'[Invoice Date] ),
            'Data Dump - Spend'[Invoice Date] <= DATE ( 2017, 6, 1 )
                && 'Data Dump - Spend'[Invoice Date] >= DATE ( 2017, 4, 1 )
        )
    )
        + 0
)
Anonymous
Not applicable

How strange! Thanks Nick.

Helpful resources

Announcements
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