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
Anonymous
Not applicable

Returning the max string value in a calculated column

Hello, 

 

Could someone help with the below please?

 

In a calculated column, I need to return the max string for a filtered set of values for differnet records. 

 

If I was doing this in SQL I would use something like:

 

 

max(case when Table2.[Task Code] in ('TASK1A1','TASK1A2,'TASK2A1','TASK2A2') then Table2.[Task Code] end)
over
(partition by Table1.[Ref No])

 

This is what my dataset looks like -  I do not want to return information on TASK3A1,TASK4A1.

 

Example2.PNG

 

I tried using MAXA to return the max string but as documented it only works with integers/dates etc. This is what I've tried so far:

 

evaluate
sumarize
(
'Table1'[Ref No],
"Max Relevant Task Stage",
calculate(maxa('Table2'[Task Code]), filter('Table2', 'Table2'[Task Code] ="TASK1A1" || 'Table2'[Task Code] ="TASK1A2" ||'Table2'[Task Code] ="TASK2A1" || 'Table2'[Task Code] ="TASK2A2" )
)
)

But it just returns '0' for the Desired Result instead of one of the four required task codes listed in the Dax. 

 

 

Could anyone show me an alternative please?

 

Thanks, 

 

pbix

 

1 REPLY 1
v-piga-msft
Resident Rockstar
Resident Rockstar

Hi @Anonymous,

 

Assuming that you have table like below.

tables.PNG

And your desired output is the calculated column which return the max string value.

 

output_.PNG

 

Please try the formula below.

 

Column =
VAR temp =
    SUMMARIZE (
        FILTER (
            'Table1',
            'Table1'[Task Code] IN { "TASK1A1", "TASK1A2", "TASK2A1", "TASK2A2" }
        ),
        Table1[Ref No],
        "Max Relevant Task Stage", CALCULATE ( MAX ( Table1[Task Code] ), VALUES ( Table1[Ref No] ) )
    )
RETURN
    MAXX (
        FILTER ( temp, [Ref No] = EARLIER ( Table3[Ref No] ) ),
        [Max Relevant Task Stage]
    )

 

 

More details, you could refer to the attachment.

 

Best Regards,

Cherry

Community Support Team _ Cherry Gao
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