Forum Discussion
Average between two columns not correct
- 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.
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.