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 September 15. Request your voucher.

Reply
Anonymous
Not applicable

How can i write dax for same version no for max line no.

Hi Everybody,

 

I want to add the yellow line mark amount. How to do it in dax. Is there anyone to help me.

 

Question: How can i write dax for same version no for max line no.

 

mzislam23_0-1678095062348.png

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1678158176917.png

(2) Click "Transform Data", enter the power query editor, click "Advanced Editor", copy and paste the following code, you can check the steps in the right step bar.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc9BCsQgDAXQu2Tdhvi/2vQGs5pVd8X7X2PswtKRqiAYeH7yz1OOz1cWOVZwNTNYHcJ17Tr14USSsgwhGqw/dqjnGWbDiPum09x40xCihhlNjW6g0t+o97XAnBWvsd43A0cbeN8rJYNyaPG3QnQqOLN45FIDpJQf", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Salesperson Code" = _t, #"Document No_" = _t, #"Version No_" = _t, #"Line No_" = _t, #"Line Amount" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Salesperson Code", type text}, {"Document No_", type text}, {"Version No_", Int64.Type}, {"Line No_", Int64.Type}, {"Line Amount", type number}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Document No_", "Document No_ - Copy"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Duplicated Column", "Document No_", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Document No_.1", "Document No_.2", "Document No_.3"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Document No_.1", type text}, {"Document No_.2", Int64.Type}, {"Document No_.3", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Document No_ - Copy", "Document No_"}}),
    #"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "Index", 1, 1, Int64.Type)
in
    #"Added Index"

(3)Click "Apply and close" and then we can create two measures.

Measure = 
 var _a=  CALCULATE(MAX('Table'[Line No_]),FILTER(ALLEXCEPT('Table','Table'[Salesperson Code],'Table'[Document No_.3],'Table'[Version No_]),'Table'[Line No_]))
 var _b= CALCULATE(MAX('Table'[Line Amount]),FILTER(ALLEXCEPT('Table','Table'[Salesperson Code],'Table'[Document No_.3],'Table'[Version No_]),'Table'[Line No_]=_a))
 return _b
color = IF(MAX('Table'[Line Amount])='Table'[Measure],1,0)

(4) Set the conditional formatting as shown in the following figure and then the result is as follows.

vtangjiemsft_2-1678158533785.png

 

vtangjiemsft_1-1678158465509.png

vtangjiemsft_3-1678158566786.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous ,

 

According to your description, here are my steps you can follow as a solution.

(1) This is my test data.  

vtangjiemsft_0-1678158176917.png

(2) Click "Transform Data", enter the power query editor, click "Advanced Editor", copy and paste the following code, you can check the steps in the right step bar.

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("fc9BCsQgDAXQu2Tdhvi/2vQGs5pVd8X7X2PswtKRqiAYeH7yz1OOz1cWOVZwNTNYHcJ17Tr14USSsgwhGqw/dqjnGWbDiPum09x40xCihhlNjW6g0t+o97XAnBWvsd43A0cbeN8rJYNyaPG3QnQqOLN45FIDpJQf", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Salesperson Code" = _t, #"Document No_" = _t, #"Version No_" = _t, #"Line No_" = _t, #"Line Amount" = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Salesperson Code", type text}, {"Document No_", type text}, {"Version No_", Int64.Type}, {"Line No_", Int64.Type}, {"Line Amount", type number}}),
    #"Duplicated Column" = Table.DuplicateColumn(#"Changed Type", "Document No_", "Document No_ - Copy"),
    #"Split Column by Delimiter" = Table.SplitColumn(#"Duplicated Column", "Document No_", Splitter.SplitTextByDelimiter("-", QuoteStyle.Csv), {"Document No_.1", "Document No_.2", "Document No_.3"}),
    #"Changed Type1" = Table.TransformColumnTypes(#"Split Column by Delimiter",{{"Document No_.1", type text}, {"Document No_.2", Int64.Type}, {"Document No_.3", Int64.Type}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type1",{{"Document No_ - Copy", "Document No_"}}),
    #"Added Index" = Table.AddIndexColumn(#"Renamed Columns", "Index", 1, 1, Int64.Type)
in
    #"Added Index"

(3)Click "Apply and close" and then we can create two measures.

Measure = 
 var _a=  CALCULATE(MAX('Table'[Line No_]),FILTER(ALLEXCEPT('Table','Table'[Salesperson Code],'Table'[Document No_.3],'Table'[Version No_]),'Table'[Line No_]))
 var _b= CALCULATE(MAX('Table'[Line Amount]),FILTER(ALLEXCEPT('Table','Table'[Salesperson Code],'Table'[Document No_.3],'Table'[Version No_]),'Table'[Line No_]=_a))
 return _b
color = IF(MAX('Table'[Line Amount])='Table'[Measure],1,0)

(4) Set the conditional formatting as shown in the following figure and then the result is as follows.

vtangjiemsft_2-1678158533785.png

 

vtangjiemsft_1-1678158465509.png

vtangjiemsft_3-1678158566786.png

If the above one can't help you get the desired result, please provide some sample data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples. It is better if you can share a simplified pbix file. Thank you.

 

Best Regards,

Neeko Tang

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

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.

Top Solution Authors