Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Counting Repeated Details

Hi  all,

 

Sample file: Sample PBIX

 

I have a table like this,

 

 

I would like to show a Card visual like this,

 

If I select an ID in slicer as "1", I need to have values shown on the card. Please ref the below screenshot,


 

How can I acheive the above result?

 

Thanks in Advance.

  • AlB's avatar
    AlB
    7 years ago

    Anonymous 

    Edited

    Create the measure below and place it in a  card visual

    Check it out in this file

     

    NewMeasure =
    VAR _Total =
        COUNT ( Sales[Detail] )
    VAR _AuxTable =
        ADDCOLUMNS (
            SUMMARIZE ( Sales; Sales[ID]; Sales[Detail] );
            "_Count"; CALCULATE ( COUNT ( Sales[Detail] ) )
        )
    VAR _MaxCount =
        MAXX ( _AuxTable; [_Count] )
    VAR _TotalMax =
        SUMX ( FILTER ( _AuxTable; [_Count] = _MaxCount ); [_Count] )
    VAR _OutputText =
        CONCATENATEX (
            FILTER ( _AuxTable; [_Count] = _MaxCount );
            [_Count] & " - " & [Detail];
            UNICHAR ( 10 )
        )
    VAR _FirstLineText = _TotalMax & "/" & _Total
    VAR _AllText =
        _FirstLineText & UNICHAR ( 10 ) & _OutputText
    RETURN
        _AllText

     

6 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Can the RANKX function will work for this kind of problem?

      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Zubair,
        The maximum detail is the max count of texts in detail column. Here, in this example, the slicer is showing ID=2, for this selection, we need to find out the maximum of Detail column.
        So, here, the repeated count is Low Price which is two times. Hence, MAX value is = 2.