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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Sridharkrish
New Member

DAX HELP WITH MAX WITH FEW CONDITIONS

Hi Everyone,

I have a table with CRM number, Name and Phase. I need to find max value with respect to the highest CRM number of the Quote (phase) alone. Though the name may consists of many other phases like agreement or leads but I need max value of highest number of the Quote. I have added a table with this message of how the result may look like. Thank you in advance.
I want DAX in PowerBi, I tried many other methods. Please help in this regard.
@FreemanZ 

CRMNamePhase Max Value
1123RahulAgreement 
1130RahulAgreement 
1125RahulAgreement 
2240GivaAgreement 
2241GivaAgreement 
2247GivaAgreement 
2250GivaQuoteMAX
2280GivaLead 
3300KichaQuote 
3301KichaQuoteMAX
3302KichaLead 
3 ACCEPTED SOLUTIONS

Hi,

Thank you for your feedback, and please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1670922833483.png

 

 

 

Max indicator of CRM number: =
VAR _maxcrmvalue =
    MAXX (
        FILTER (
            ALL ( Data ),
            Data[Name] = MAX ( Data[Name] )
                && Data[Phase] = "Quote"
        ),
        Data[CRM]
    )
RETURN
    IF ( MAX ( Data[CRM] ) = _maxcrmvalue, "MAX" )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

Hi,

Please check the below picture and the attached pbix file.

The below is for creating a new column.

 

Jihwan_Kim_0-1670928288937.png

 

Max CRM number indicator CC = 
VAR _maxcrmvalue =
    MAXX (
        FILTER (
            Data ,
            Data[Name] = EARLIER( Data[Name] )
                && Data[Phase] = "Quote"
        ),
        Data[CRM]
    )
RETURN
    IF ( Data[CRM]  = _maxcrmvalue, "MAX" )

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


View solution in original post

Hi @Sridharkrish 

 

You may also try this code:

MaxValue =
VAR _name = [Name]
VAR _max = MAXX(
    FILTER(
        'Table',
        'Table'[Name] = _name&&'Table'[Phase ] = "Quote"
    ),
    'Table'[CRM]
)
RETURN IF([CRM]=_max, "MAX")
 
i tried and it worked like this:
FreemanZ_0-1670929126956.png

View solution in original post

8 REPLIES 8
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1670917341261.png

 

 

Max value of CRM number: =
IF (
    HASONEVALUE ( Data[Name] ),
    MAXX ( FILTER ( Data, Data[Phase] = "Quote" ), Data[CRM] )
)

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Hi,
I have a table consisting of name, CRM number and a phase where I need to find the max value of the CRM number. I have three conditions here : I want DAX in PowerBi.
If a name has only agreements in the phase then there shouldnt be any max value.
If a name consists of agreements, quotes and leads then the max value should be of the highest number of the CRM in the quote as per particular name.
If a name consists of multiple Quotes in CRM then they should be of the highest number of CRM in the quote. I have attached an example of how the value should be displayed for your refererance.

Sridharkrish_0-1670921218210.png

I have tried many methods but couldnt find any solution please help me in this regard.

Hi,

Thank you for your feedback, and please check the below picture and the attached pbix file.

 

Jihwan_Kim_0-1670922833483.png

 

 

 

Max indicator of CRM number: =
VAR _maxcrmvalue =
    MAXX (
        FILTER (
            ALL ( Data ),
            Data[Name] = MAX ( Data[Name] )
                && Data[Phase] = "Quote"
        ),
        Data[CRM]
    )
RETURN
    IF ( MAX ( Data[CRM] ) = _maxcrmvalue, "MAX" )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Can I know how to add this as a column but not as a measure.

Hi,

Please check the below picture and the attached pbix file.

The below is for creating a new column.

 

Jihwan_Kim_0-1670928288937.png

 

Max CRM number indicator CC = 
VAR _maxcrmvalue =
    MAXX (
        FILTER (
            Data ,
            Data[Name] = EARLIER( Data[Name] )
                && Data[Phase] = "Quote"
        ),
        Data[CRM]
    )
RETURN
    IF ( Data[CRM]  = _maxcrmvalue, "MAX" )

 

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Go to My LinkedIn Page


Thanks this worked out as well !

 

Hi @Sridharkrish 

 

You may also try this code:

MaxValue =
VAR _name = [Name]
VAR _max = MAXX(
    FILTER(
        'Table',
        'Table'[Name] = _name&&'Table'[Phase ] = "Quote"
    ),
    'Table'[CRM]
)
RETURN IF([CRM]=_max, "MAX")
 
i tried and it worked like this:
FreemanZ_0-1670929126956.png

This also wroked out thanks !

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors