Forum Discussion

flavio29's avatar
flavio29
Frequent Visitor
5 years ago
Solved

Count values inside and outside objective

Hello, i have the following data: Date Code Values Avg values based on each code Count distinct codes Count codes out of objective (<33) Count codes inside objective (>=33) 1/1/2021 1...
  • MFelix's avatar
    5 years ago

    Hi flavio29 

     

    You need to create the following measures:

     

    Average_values_per_item =
    AVERAGEX (
        FILTER (
            ALLSELECTED ( 'Table'[Code], 'Table'[Values] ),
            'Table'[Code] = SELECTEDVALUE ( 'Table'[Code] )
        ),
        'Table'[Values]
    )
    
    DistinctCount = DISTINCTCOUNT('Table'[Code])
    
    below =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Code] ),
        FILTER ( ALLSELECTED ( 'Table'[Values] ), [Average_values_per_item] < 33 )
    )
    
    above =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Code] ),
        FILTER ( ALLSELECTED ( 'Table'[Values] ), [Average_values_per_item] >= 33 )
    )
    

     

    Has you can see below and in attach PBIX file result are correct.