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

sum of amount corresponding to date range

Hi All,

Below is my sample data,

RohiniP-26_0-1610220274228.png

Expected output: ( date filter 01-02-2020 to 31-03-2020)

RohiniP-26_2-1610221258096.png

Assume that, I have data upto 30-04-2020.

I need to calculate the last 3 columns (as measures) and want to show the sum of sales amount where 'End total'=1.

Problem is that, I don't have date value, where 'End total'=1. This row is just to show the sum.

1) sum amount (selected range) - sum of sales amount between selected date range in the date filter.

2) sum amount (before selected range) - sum of sales amount, date ranges from begining (in this ex 01-01-2020) to the max selected date (To date in date filter).

3) sum amount (upto last date) - sum of sales amount which is not affected by date filter, that includes all date (ie from begining to ending of data).

 

Thanks in advance.......

1 ACCEPTED SOLUTION
littlemojopuppy
Community Champion
Community Champion

Hi @Anonymous 

 

Try these measures

Total Sales = SUM(Sales[Sales Amount])

Sales in Date Range = 
    IF(
        ISFILTERED(Sales[Date]),
        BLANK(),
        CALCULATE(
            [Total Sales],
            VALUES('Calendar'[Date])
        )
    )

Sales Before Date Range = 
    VAR MaximumDate =
        MAXX(
            VALUES('Calendar'[Date]),
            'Calendar'[Date]
        )
    RETURN

    IF(
        ISFILTERED(Sales[Date]),
        BLANK(),
        CALCULATE(
            [Total Sales],
            'Calendar'[Date] <= MaximumDate
        )
    )

All Sales = 
    IF(
        ISFILTERED(Sales[Date]),
        BLANK(),
        CALCULATE(
            [Total Sales],
            ALL('Calendar'[Date])
        )
    )

 

Here's the results

littlemojopuppy_0-1610302304464.png

 

Hope this helps!  🙂

View solution in original post

2 REPLIES 2
littlemojopuppy
Community Champion
Community Champion

Hi @Anonymous 

 

Try these measures

Total Sales = SUM(Sales[Sales Amount])

Sales in Date Range = 
    IF(
        ISFILTERED(Sales[Date]),
        BLANK(),
        CALCULATE(
            [Total Sales],
            VALUES('Calendar'[Date])
        )
    )

Sales Before Date Range = 
    VAR MaximumDate =
        MAXX(
            VALUES('Calendar'[Date]),
            'Calendar'[Date]
        )
    RETURN

    IF(
        ISFILTERED(Sales[Date]),
        BLANK(),
        CALCULATE(
            [Total Sales],
            'Calendar'[Date] <= MaximumDate
        )
    )

All Sales = 
    IF(
        ISFILTERED(Sales[Date]),
        BLANK(),
        CALCULATE(
            [Total Sales],
            ALL('Calendar'[Date])
        )
    )

 

Here's the results

littlemojopuppy_0-1610302304464.png

 

Hope this helps!  🙂

My solution assumes you have a date table and it is marked accordingly.

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.