Forum Discussion

AndreaSo's avatar
AndreaSo
Frequent Visitor
4 years ago
Solved

Return text value from column A when contains different values in column B.

Hi

 

I am new to DAX and I need to return the value from column A (in this case X23) because it contains different values in column B.

 

Please see the table below:

 

AB
X23D566
X23D555
X15D566
X14D566
X18D555
X18D555
  • Hi AndreaSo ,

     

    You can try below formula:

    Result = 
    VAR a =
        COUNTROWS ( FILTER ( ALL ( 'Table' ), 'Table'[A] = MAX ( 'Table'[A] ) ) )
    VAR b =
        COUNTROWS (
            FILTER (
                ALL ( 'Table' ),
                'Table'[A] = MAX ( 'Table'[A] )
                    && 'Table'[B] = MAX ( 'Table'[B] )
            )
        )
    RETURN
        IF ( a = b,  "black" ,"red")

     

    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


    Best Regards,
    Henry


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

2 Replies

  • In a table visual add columns A and B. Change the aggregation for B to Count (Distinct).  Apply a visual filter where that value has to be greater than 1.

  • v-henryk-mstf's avatar
    v-henryk-mstf
    Icon for Community Support rankCommunity Support

    Hi AndreaSo ,

     

    You can try below formula:

    Result = 
    VAR a =
        COUNTROWS ( FILTER ( ALL ( 'Table' ), 'Table'[A] = MAX ( 'Table'[A] ) ) )
    VAR b =
        COUNTROWS (
            FILTER (
                ALL ( 'Table' ),
                'Table'[A] = MAX ( 'Table'[A] )
                    && 'Table'[B] = MAX ( 'Table'[B] )
            )
        )
    RETURN
        IF ( a = b,  "black" ,"red")

     

    If the problem is still not resolved, please provide detailed error information and let me know immediately. Looking forward to your reply.


    Best Regards,
    Henry


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