Forum Discussion

ank1997's avatar
ank1997
Microsoft Employee
4 years ago
Solved

DAX Function for finding the average

Hi all!    I have been stuck on this for a while and was wondering if anyone can help me!   I have an excel that has a list of job ID numbers (some that are repeated, 200+ rows) in one column and...
  • v-cazheng-msft's avatar
    4 years ago

    Hi ank1997 ,

     

    You may try this Measure if you still have problems on it.

    CurrentStatusAvgForPerID =
    
    VAR CountStatus =
    
        CALCULATE (
    
            COUNT ( 'Table'[current_status] ),
    
            ALLEXCEPT ( 'Table', 'Table'[job_id], 'Table'[current_status] )
    
        )
    
    VAR CountStatusPerID =
    
        CALCULATE (
    
            COUNT ( 'Table'[current_status] ),
    
            ALLEXCEPT ( 'Table', 'Table'[job_id] )
    
        )
    
    VAR Table_ =
    
        SUMMARIZE (
    
            VALUES ( 'Table' ),
    
            'Table'[job_id],
    
            'Table'[current_status],
    
            "Div", CountStatus / CountStatusPerID
    
        )
    
    RETURN
    
        SUMX ( Table_, [Div] )

     

    The result should look like this.

     

    Also, attached the pbix file as reference.

     

    If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

     

    Best Regards,

    Community Support Team _ Caiyun