Forum Discussion

jhlatinia's avatar
jhlatinia
New Member
3 years ago
Solved

Average between two columns not correct

Hello, I've been trying to calculate the average of the division of 2 columns in PowerBi Desktop and not receive the right results. As you can see the column CTR is returning 0,66% for the fi...
  • v-jianboli-msft's avatar
    3 years ago

    Hi jhlatinia ,

     

    The result you get is incorrect is because it is the sum of all rows. In other words, they calculate the percentage of each row first and then sum it, which gives a different result than summing and then calculating the percentage.

    Please try:

    CTR = 
    VAR _a =
        SUMMARIZE (
            'Table',
            'Table'[Campaign Group Name],
            "CTR",
                DIVIDE (
                    CALCULATE (
                        SUM ( 'Table'[Clicks] ),
                        FILTER (
                            'Table',
                            [Campaign Group Name] = EARLIER ( 'Table'[Campaign Group Name] )
                        )
                    ),
                    CALCULATE (
                        SUM ( 'Table'[Impressions] ),
                        FILTER (
                            'Table',
                            [Campaign Group Name] = EARLIER ( 'Table'[Campaign Group Name] )
                        )
                    )
                )
        )
    RETURN
        AVERAGEX ( _a, [CTR] )
    

    Final output:

    Best Regards,

    Jianbo Li

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