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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
hanssonnor
Frequent Visitor

Problem MAXX function with string

Hi,

 

I am currently working on a measure using the following table:

 

NumberItemReason CodeStatusCenter
60607788abc0B10G1A30
60607788abc0B20G1G30
60607788abc0B30G1C30
60607788abc0B40G1T40
60607788abc0B50G1X50
60607788abc0B60G1S20
60607788abc0B70G1R40
60607788abc0B80G1L30
60607788abc0B90G1H40
60607789bbc0B10G1A30
60607789bbc0B20G1G30
60607789bbc0B30G1C30
60607789bbc0B40G1T40
60607789bbc0B50G1X50
60607789bbc0B60G1S20
60607789bbc 70G1R40
60607789bbc 80G1L30
60607789bbc 90G1H40

 

I am using the following measure:

 

 

Last CC = 

VAR MaxStatus = MAX('Work Order Time Transactions'[Status])
Return
MAXX(
    FILTER(
        'Work Order Time Transactions',
        MaxStatus
        && 'Work Order Time Transactions'[Reason Code] = "0B"
    ),
    'Work Order Time Transactions'[Center]
)

 

 

The measure works but does not give me the desired result. For the table above I want to know the last Center for maximum Status and reason Code 0B. In the table, the results for abc should be G1H40 since the maximum Status with reason Code 0B is 90, but the measure computes G1X50 since the string is the biggest. I found the gap in my measure but I am struggling to solve it. 

 

I gladly appreciate any hints to solve this issue.

 

Thanks & Best regards

Hansson

1 ACCEPTED SOLUTION

Hi Amit,

 

thanks a lot,  it works 🙂

 

Best regards

Arne

 

View solution in original post

5 REPLIES 5
colacan
Resolver II
Resolver II

MAXCC =
VAR maxStatus =
    CALCULATE (
        MAX ( 'Work Order Time Transactions'[Status] ),
        ALLEXCEPT (
            'Work Order Time Transactions',
            'Work Order Time Transactions'[Item]
        ),
        'Work Order Time Transactions'[Reason Code] = "0B"
    )
RETURN
    CALCULATE (
        SELECTEDVALUE ( 'Work Order Time Transactions'[Center] ),
        'Work Order Time Transactions'[Status] = maxStatus
    )

Hi Colacan,

 

thanks for your approach. I had to modify it though, with the Allexcept it did not work. However once I removed that filter it showed the same results.

 

Best regards

Hansson

@hanssonnor  Hi Hanssonnor, I have noticed that extracting highest or lowest recode within categories is quite tipical problem which lots of people are facing. And Allexcept function is quite useful for those problems.

Cheers!

amitchandak
Super User
Super User

@hanssonnor , Try a measure like

calculate(lastnonblankvalue('Work Order Time Transactions'[Status], max('Work Order Time Transactions'[Center])),'Work Order Time Transactions'[Reason Code] = "0B")

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi Amit,

 

thanks a lot,  it works 🙂

 

Best regards

Arne

 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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