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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
RJMonteza
Regular Visitor

Need help to build DAX to get the sum of the latest version.

I have 5 columns:

1. Quote Number (seen as 123456)

2. Sales

3. Quote Number / Version (seen as "123456:1" being 1 as the number of version)

4. Period

5. Owner

 

What I need is to get the total sales per period of the latest version of the Quote with selected Owners only. There are more than 20 owners but I only need 10 of them. (with specific names)

 

I had done some experiments but I can't get it through.

 

Thanks!

4 REPLIES 4
Anonymous
Not applicable

Hi @RJMonteza ,

Please try below dax formula:

1. Below is my test table

Table:

vbinbinyumsft_0-1674625987505.png

2. Create a measure with below dax formula

Measure =
VAR _a =
    ADDCOLUMNS (
        'Table',
        "Version",
            RIGHT (
                'Table'[Quote/Version],
                LEN ( 'Table'[Quote/Version] ) - LEN ( 'Table'[Quote Number] ) - 1
            )
    )
VAR _b =
    SUMX (
        FILTER (
            _a,
            [Version]
                = MAXX (
                    FILTER ( _a, [Quote Number] = EARLIER ( 'Table'[Quote Number] ) ),
                    [Version]
                )
        ),
        [Sales]
    )
RETURN
    IF ( ISINSCOPE ( 'Table'[Quote Number] ), SUM ( 'Table'[Sales] ), _b )

3. Add a table visual with fields and measure 

vbinbinyumsft_1-1674626104047.png

Please refer the attached .pbix file.

 

Best regards,
Community Support Team_Binbin Yu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hello!

 

I think I'm getting there. I'm trying to add a filter to include only the names that needed to sum up the sales. Example: 

Measure =
VAR _a =
    ADDCOLUMNS (
        'Table',
        "Version",
            RIGHT (
                'Table'[Quote/Version],
                LEN ( 'Table'[Quote/Version] ) - LEN ( 'Table'[Quote Number] ) - 1
            )
    )
VAR _b =
    SUMX (
        FILTER (
            _a,
            [Version]
                = MAXX (
                    FILTER ( _a, [Quote Number] = EARLIER ( 'Table'[Quote Number] ) ),
                    [Version]
                )
        ),
        [Sales]
    )
RETURN
CALCULATE(
    IF ( ISINSCOPE ( 'Table'[Quote Number] ), SUM ( 'Table'[Sales] ), _b ),
    'Table'[TSE] IN {"JOHN","DAVID","CINDY","JESSICA","MICHAEL","JOAN","MAY","NICOLE","MARY"})
 
This is somehow working on the other measures but I think it's not working here. The sum is not changing. I also tried to create VAR _C to filter these names like:
 
VAR _c =
    CALCULATE(_b,
        FILTER('Table',CONTAINS('Table','Table'[TSE], "JOHN",'Table'[TSE],"DAVID",'Table'[TSE],"CINDY",'Table'[TSE],"JESSICA",'Table'[TSE],"MICHAEL",'Table'[TSE],"JOAN",'Table'[TSE],"MAY",'Table'[TSE],"NICOLE",'Table'[TSE],"MARY")
 
RETURN
IF ( ISINSCOPE ( ''TABLE'[QUOTE NUMBER] ), SUM ( 'TABLE'[SALES] ), _c)
 
But I'm gettin an error that my syntax for return is incorrect.

 

FreemanZ
Super User
Super User

hi @RJMonteza 

not sure if fully get you, you may try like:

 

Measure =
VAR _table =
ADDCOLUMNS(
    SUMMARIZE(
        TableName,
        TableName[Quote Number],
        TableName[Period]
    ),
    "LatestQuoteVersion",
    CALCULATE(MAX(TableName[uote Number / Version]))
)
RETURN
CALCULATE(
    SUM(TableName[Sales]),
    TREATAS(
        _table, 
        TableName[Quote Number], 
        TableName[Period],
        TableName[Quote Number / Version]
    )
)

 

Hello FreemanZ,

 

I created a table to further explain:

 

pbi.PNG

 

I need the sum of the highlighted cells. I'm struggling to catch it as I do not have a date. I only have the Quote/Version.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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