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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.