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
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
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.