Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Count occurrences ????

I have a table which contains all possible values eg:  And I have another table :    I need to count how often each value appears like this:  But how do I realize this ?!?!
  • Jihwan_Kim's avatar
    4 years ago

    Hi,

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

     

     

    Occurrences: =
    VAR currentvalue =
    MAX ( 'Values'[Values] )
    RETURN
    IF (
    HASONEVALUE ( 'Values'[Values] ),
    CALCULATE ( COUNTROWS ( Data ), FILTER ( Data, Data[Column1] = currentvalue ) )
    + CALCULATE ( COUNTROWS ( Data ), FILTER ( Data, Data[Column2] = currentvalue ) )
    + CALCULATE ( COUNTROWS ( Data ), FILTER ( Data, Data[Column3] = currentvalue ) )
    )