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

Amount Total for date values between two date columns

How do I calculated the total of amounts invoiced between two date columns.

 

Example:I have three columns - Date Invoiced, Date Paid and Amount. I want to create a column or measure that shows the aggregated amount of all invoices for invoice dates between the date invoiced and date paid.

So for the first row, the value for this column/measure should be the sum of amount for all invoices that have an invoice date between Invoice Date(6/30/2021) and Date Paid(7/2/2021). So if invoice date and date paid are the same for two records, then this value should be the same for the two records.

 

Example.PNG

1 ACCEPTED SOLUTION
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

Measure = 
VAR _curinvdate =
    SELECTEDVALUE ( 'Table'[Invoice date] )
VAR _curpaiddate =
    SELECTEDVALUE ( 'Table'[Date paid] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Amount(USD)] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Invoice date] >= _curinvdate
                && 'Table'[Date paid] <= _curpaiddate
        )
    )

yingyinr_1-1628490295225.png

If the above one is not what you want, please provide some sample data with Text format and your expected result with calculation logic and special examples. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yiruan-msft
Community Support
Community Support

Hi @Anonymous ,

I created a sample pbix file(see attachment) for you, please check whether that is what you want.

Measure = 
VAR _curinvdate =
    SELECTEDVALUE ( 'Table'[Invoice date] )
VAR _curpaiddate =
    SELECTEDVALUE ( 'Table'[Date paid] )
RETURN
    CALCULATE (
        SUM ( 'Table'[Amount(USD)] ),
        FILTER (
            ALLSELECTED ( 'Table' ),
            'Table'[Invoice date] >= _curinvdate
                && 'Table'[Date paid] <= _curpaiddate
        )
    )

yingyinr_1-1628490295225.png

If the above one is not what you want, please provide some sample data with Text format and your expected result with calculation logic and special examples. Thank you.

Best Regards

Community Support Team _ Rena
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
madhavan2427
Frequent Visitor

Hello @Anonymous , 

As much I understand your problem I am giving you a helping hand, 

You have to create a date table as DimDate and establish a relationship with the existing table first, then
Create a column as:

= Calculate(sum(Amont), DatesBetween(DimDate[Date], (invoice Date), (Date paid)))

 

Hope this will help you.

#Keep Learning #Keep Helping.

 

amitchandak
Super User
Super User

@Anonymous , expected output is not clear.

 

But you can have a common date table. Join Date Invoiced, Date Paid with that. And one join will inactive and then you can use userelationship in a measure to activate the join

 

refer example here

https://community.powerbi.com/t5/Community-Blog/HR-Analytics-Active-Employee-Hire-and-Termination-trend/ba-p/882970

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.