Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago
Solved

DAX fix on Average function

Experts,

please help me to fix the below DAX code.

 

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi Anonymous ,

     

    Please try this measure:

    Measure = 
    AVERAGEX(
        VALUES('Query1'[Index]),
        DIVIDE(
            CALCULATE(
                SUM('Query1'[Number of Orders]),
                    'Query1'[Early Delivery Flag]="Y"
                )+0,
                CALCULATE(
                    SUM('Query1'[Number of Orders]),
                    ALL()
                )
            )
    )

    Where the value in 'Query1'[Index] is uniquely and not null. If the table 'Query1' does not have a column that meets such a condition, you can add a new column in the Power Query Editor.

    Best Regards,
    Gao

    Community Support Team

     

    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 us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data

3 Replies

  • tamerj1's avatar
    tamerj1
    Community Champion

    Hi Anonymous 
    You can right it 
    ( DIVIDE formula + SUM formula ) /2

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

     

    Please try this measure:

    Measure = 
    AVERAGEX(
        VALUES('Query1'[Index]),
        DIVIDE(
            CALCULATE(
                SUM('Query1'[Number of Orders]),
                    'Query1'[Early Delivery Flag]="Y"
                )+0,
                CALCULATE(
                    SUM('Query1'[Number of Orders]),
                    ALL()
                )
            )
    )

    Where the value in 'Query1'[Index] is uniquely and not null. If the table 'Query1' does not have a column that meets such a condition, you can add a new column in the Power Query Editor.

    Best Regards,
    Gao

    Community Support Team

     

    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 us know. Thanks a lot!

    How to get your questions answered quickly -- How to provide sample data