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
TonyRoo
New Member

Sum amount between start and end date

I've reviews a couple of the posts on here that show how to calculate a value between two dates but its they are not quite what I am looking for.

 

I have a dates tables that represents fiscal calendar weeks; it has a start and end date specified.

I would like an additonal "Total Amount" column on this table that is a sum of the Amount field from another table between those dates.

 

DatesTable

 

 

StartDateEndDateTotalAmount
1 May7 May150
8 May14 May75

 

AmountsTable

 

 

DateAmount
2 May50
7 May100
8 May25
10 May25
13 May25

 

 

I've tried

 

TotalAmount = Calculate(SUM(AmountsTable[Amount]), FILTER(AmountsTable,AmountsTable[Date] <=

 

but then it won't let me add the Start or End date as a filter from the DatesTable.

 

I am sure this is something super easy but any help greatly appreciated.

 

 

1 ACCEPTED SOLUTION

@TonyRoo

 

if you are adding it as a calculated column, it should allow you to add Start and End dates,
In case of MEASURE you can wrap them inside selectedvalue function

 

sumamountdates.png

 

 

As a MEASURE

 

Total Amount =
CALCULATE (
    SUM ( AmountsTable[Amount] ),
    FILTER (
        AmountsTable,
        AmountsTable[Date] <= SELECTEDVALUE ( DatesTable[EndDate] )
            && AmountsTable[Date] >= SELECTEDVALUE ( DatesTable[StartDate] )
    )
)

Regards
Zubair

Please try my custom visuals

View solution in original post

2 REPLIES 2
Zubair_Muhammad
Community Champion
Community Champion

@TonyRoo

 

TotalAmount =
CALCULATE (
    SUM ( AmountsTable[Amount] ),
    FILTER (
        AmountsTable,
        AmountsTable[Date] <= DatesTable[EndDate]
            && AmountsTable[Date] >= DatesTable[StartDate]
    )
)

Regards
Zubair

Please try my custom visuals

@TonyRoo

 

if you are adding it as a calculated column, it should allow you to add Start and End dates,
In case of MEASURE you can wrap them inside selectedvalue function

 

sumamountdates.png

 

 

As a MEASURE

 

Total Amount =
CALCULATE (
    SUM ( AmountsTable[Amount] ),
    FILTER (
        AmountsTable,
        AmountsTable[Date] <= SELECTEDVALUE ( DatesTable[EndDate] )
            && AmountsTable[Date] >= SELECTEDVALUE ( DatesTable[StartDate] )
    )
)

Regards
Zubair

Please try my custom visuals

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.