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

Sum of cost filtering minimum date (DAX)

Dear Team,

I need help to return the following,

 

For every Project Number in the table ,I want to calculate the sum of ‘Cost’ that has the minimum ‘Date’ present for that project number and a ‘Status’= L .

 

Project Number            Status             Date              Cost

        1                               L                12/4/2020        10

        1                               L                12/4/2020        10

        1                               L                12/18/2020        5

        1                               N                1/14/2020         8

 

I need to return, cost = 20 for Project Number 1 having a date 12/4/2020 &Status 'L'. Kindly suggest

 

 

4 REPLIES 4
ronbermudez
Helper I
Helper I

Thanks for helping me solve my long time problem.  The solution contained in this thread gave me a good clue to solve my own challenging DAX problem!

 

Thanks!

AlB
Super User
Super User

Hi @Anonymous 

1. Place Project Number in a table visual

2. Place this measure in the visual 

Measure =
CALCULATE (
    VAR lastDate_ =
        MIN ( Table1[Date] )
    RETURN
        CALCULATE ( SUM ( Table1[Cost] ), Table1[Date] = lastDate_ ),
    Table1[Status] = "L"
)

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

 

Anonymous
Not applicable

Hello AIB,

 

Thank you so much for your quick response. I did use the measure suggested and the table view returns no value. The project number is the unique key that drives Cost, Status and Date. Do we need to incorporate that in the query as well ?PBI.png

 Thanks in advance!

 

@Anonymous 

It's working on my side. See it all at work in the attached file.

You can also select the "L" on a slicer rather than having it hardcoded in the measure

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

 

SU18_powerbi_badge

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.

Top Solution Authors
Top Kudoed Authors