Forum Discussion

kralco626's avatar
kralco626
Frequent Visitor
8 years ago
Solved

Calculate average, std for each category

I have two tables   Work: Work ID (unique) Work Type Work Group   Entries: Work ID (points to Work table) Hours Dollars   Basically, this represents work we do, and each entry that someon...
  • Anonymous's avatar
    Anonymous
    8 years ago

    Hi kralco626,

     

    You can try to use below measure to get grouped average value:

     

    Average = 
    VAR idlist =
        CALCULATETABLE (
            VALUES ( 'Work'[Work ID] ),
            FILTER ( ALLSELECTED('Work'), 'Work'[Work Type] = MAX ( 'Work'[Work Type] ) )
        )
    RETURN
        DIVIDE (
            SUMX ( FILTER (ALLSELECTED( Entries), [Work ID] IN idlist ), [Hours] ),
            COUNTROWS ( idlist ),
            0
        )
    

     

    Regards,

    Xiaoxin Sheng