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

Get certified in Microsoft Fabric—for free! For a limited time, the Microsoft Fabric Community team will be offering free DP-600 exam vouchers. Prepare now

Reply
coetseem
Regular Visitor

DAX or Add of Column

Good Day, 

I need some help with the below example.

The bold colour is the raw data extracted from my system.

Keep in mind that the data comes from two data sets where it is match so the created date will be the same for all but the final creation date will differ as the deal goes through stages untill it is finalized.

 

1. What i want to do is to only add one value in the quotevaluefixed2 and QuoteValueRecurring3 based on the max final creation date.

2. Work out the age in days where the max Final Creation Date - Created Date.

3. Work out the final stage based on the max Final Creation Date

 

See red as example what i want to achieve, all of this is based on the ID as well as dates.

 

IDQuoteValueFixedQuoteValueRecurringCreatedFinal Creation DateStatus QuoteValueFixed2  QuoteValueRecurring3 DaysFinal Stage
3495.2502023/09/12 13:272023/09/12 13:27 a - Request Raised     
3495.2502023/09/12 13:272023/09/12 13:58 b - Request Approved     
3495.2502023/09/12 13:272023/09/13 12:14 d - Quote Raised     
3495.2502023/09/12 13:272023/09/13 12:14 e - Quote Financial Approval 1     
3495.2502023/09/12 13:272023/09/13 12:16 i - Quote Approved     
3495.2502023/09/12 13:272023/09/13 12:17 j - Quote Approved To Send                              495.25                                               -  0.95j - Quote Approved To Send
1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@coetseem , Try a new column like

 

if([Creation date] = maxx(filter(Table, [ID] = earlier([ID]) ), [creation Date]) , [Quote Value] , Blank())

 

for measure try like

 

Latest
https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

https://amitchandak.medium.com/power-bi-get-the-sum-of-the-last-latest-value-of-a-category-f1c839ee8...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

View solution in original post

2 REPLIES 2
v-xinruzhu-msft
Community Support
Community Support

Hi @coetseem 

Based on the @amitchandak 's solution, you can also consider to create measures, they can dynamically changed.

e.g 

QuoteValueFixed2 =
VAR a =
    CALCULATE (
        MAX ( 'Table'[Final Creation Date] ),
        ALLEXCEPT ( 'Table', 'Table'[ID] )
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Table'[Final Creation Date] ) = a,
        SUM ( 'Table'[QuoteValueFixed] )
    )
QuoteValueRecurring3 =
VAR a =
    CALCULATE (
        MAX ( 'Table'[Final Creation Date] ),
        ALLEXCEPT ( 'Table', 'Table'[ID] )
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Table'[Final Creation Date] ) = a,
        SUM ( 'Table'[QuoteValueRecurring] )
    )
Days =
VAR a =
    CALCULATE (
        MAX ( 'Table'[Final Creation Date] ),
        ALLEXCEPT ( 'Table', 'Table'[ID] )
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Table'[Final Creation Date] ) = a,
        DATEDIFF ( MAX ( 'Table'[Created] ), a, DAY )
    )
Final Stage =
VAR a =
    CALCULATE (
        MAX ( 'Table'[Final Creation Date] ),
        ALLEXCEPT ( 'Table', 'Table'[ID] )
    )
RETURN
    IF (
        SELECTEDVALUE ( 'Table'[Final Creation Date] ) = a,
        MAX ( 'Table'[Status] )
    )

Output

vxinruzhumsft_0-1696217637167.png

Best Regards!

Yolo Zhu

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

 

amitchandak
Super User
Super User

@coetseem , Try a new column like

 

if([Creation date] = maxx(filter(Table, [ID] = earlier([ID]) ), [creation Date]) , [Quote Value] , Blank())

 

for measure try like

 

Latest
https://amitchandak.medium.com/power-bi-get-the-last-latest-value-of-a-category-d0cf2fcf92d0

https://amitchandak.medium.com/power-bi-get-the-sum-of-the-last-latest-value-of-a-category-f1c839ee8...

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
OCT PBI Update Carousel

Power BI Monthly Update - October 2024

Check out the October 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.

October NL Carousel

Fabric Community Update - October 2024

Find out what's new and trending in the Fabric Community.