Forum Discussion

cheryl0316's avatar
cheryl0316
Icon for Helper II rankHelper II
1 year ago
Solved

AVERAGEX returns blank

This is a sample report regarding employee performance.   If an employee doesn't meet the sales target, he will receive a notice. If an employee exceeds the maximum allowed refund amount, he will...
  • Anonymous's avatar
    Anonymous
    1 year ago

    Hi cheryl0316 

     

    Certainly!

     

    The SELECTEDVALUE() returns blank when the Slicer Number of Notice is all, because there are multipal values being selected. Please refere to this link:

    SELECTEDVALUE function - DAX | Microsoft Learn

     

    So change the measure this way:

    Average_Notice =
    VAR a =
        SUMMARIZECOLUMNS (
            dimLocation[Country],
            dimLocation[City],
            dimEmployee[Employee Name],
            dimProduct[Product Category]
        )
    VAR b =
        ADDCOLUMNS (
            a,
            "n", CALCULATE ( [Number_Notice] ),
            "sa", CALCULATE ( [Sum_Sales Amount] )
        )
    RETURN
        IF (
            SELECTEDVALUE ( Notice[Number] ) <> BLANK (),
            AVERAGEX (
                FILTER ( b, [sa] > 0 && [n] = SELECTEDVALUE ( Notice[Number] ) ),
                [n]
            ),
            AVERAGEX ( FILTER ( b, [sa] > 0 ), [n] )
        )
    

     

    The result is as follow:

     

     

    Best Regards

    Zhengdong Xu
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.