Forum Discussion

merlingsf's avatar
merlingsf
Frequent Visitor
6 years ago
Solved

Max value from two columns - Show blanks

Hi,

 

I am having trouble geting a single max value for a row from three columns in a matrix.

 

The columns are: Name, Date(Month), Price

The Dataset:

 

NameMonthPrice
AJanuary75.000
AJanuary150.000
AMarch250.000
BJanuary350.000
BJanuary175.000
BMarch150.000
CMarch75.000
CMarch65.000
CJanuary125.000

 

A simple Max() Formula will result in:

NameJanuaryMarchTotal (Max)
A150.000250.000250.000
B350.000150.000350.000
C125.00075.000125.000
Total (Max)350.000250.000 

 

What I am aiming for:

NameJanuaryMarchTotal (Max)
A 250.000250.000
B350.000 350.000
C   
Total (Max)350.000250.000 

 

So, it should show a blank when the the Max value is not valid in this context. C does not have the max price in either January or March hence blank.

 

Any suggestions?

  • Hi merlingsf ,

     

    We can try to create a measure to meet your requirement:

     

    Measure =
    SUMX (
        DISTINCT ( 'Table'[Month] ),
        VAR result =
            MAXX (
                CALCULATETABLE ( DISTINCT ( 'Table'[Name] ), ALLSELECTED () ),
                CALCULATE ( MAX ( 'Table'[Price] ) )
            )
        RETURN
            IF ( CALCULATE ( MAX ( 'Table'[Price] ) ) = result, result, BLANK () )
    )

     

     


    By the way, PBIX file as attached.


    Best regards,

     

2 Replies

  • v-lid-msft's avatar
    v-lid-msft
    Icon for Community Support rankCommunity Support

    Hi merlingsf ,

     

    We can try to create a measure to meet your requirement:

     

    Measure =
    SUMX (
        DISTINCT ( 'Table'[Month] ),
        VAR result =
            MAXX (
                CALCULATETABLE ( DISTINCT ( 'Table'[Name] ), ALLSELECTED () ),
                CALCULATE ( MAX ( 'Table'[Price] ) )
            )
        RETURN
            IF ( CALCULATE ( MAX ( 'Table'[Price] ) ) = result, result, BLANK () )
    )

     

     


    By the way, PBIX file as attached.


    Best regards,

     

    • merlingsf's avatar
      merlingsf
      Frequent Visitor

      Hi v-lid-msft,

       

      Thank you so much for taking the time to look at this.

       

      This seems to solve the problem.