Forum Discussion
Anonymous
9 years agoNot applicable
Dynamic benchmarking calculation based on slicer selection
Hello, I have a dataset that looks something like this: Campaign Mailing List Date Open Rate A Subscribers 01/05/2016 15% B Competition 03/09/2016 17% C Competition 25/...
- 9 years ago
Anonymous
Hi George,
I've used your "Similar Mailing List" example, but similar logic should apply for your other example.
Before getting into the DAX, you need a measure that:
- Captures the Mailing Lists of currently selected Campaigns and adds to the filter context
- Clears the Campaign filter
- Calculates the Average Open Rate in this modified context
If I call your table Data, this sort of pattern would work:
Open Rate Average = AVERAGE ( Data[Open Rate] ) Open Rate Average for Same Mailing List as Selected Campaigns = CALCULATE ( [Open Rate Average], SUMMARIZE ( Data, Data[Mailing List] ), ALL ( Data[Campaign] )
)Notes:
- SUMMARIZE ( Data, Data[Mailing List] ) could be replaced with VALUES ( Data[Mailing List] ) since there is just a single table here, but SUMMARIZE would be needed if Mailing List was in a lookup table.
- The columns specified in SUMMARIZE determine the common attributes over which you want to calculate the average, so you can tweak this to whatever attributes you want.
- I cleared only the Campaign filter using ALL, so any other filters (date etc) are still applied. You could tweak this to clear more filters if you needed to.
Hope that helps as a starting point.
Cheers,
Owen :)
OwenAuger
9 years agoSuper User
Anonymous
Hi George,
I've used your "Similar Mailing List" example, but similar logic should apply for your other example.
Before getting into the DAX, you need a measure that:
- Captures the Mailing Lists of currently selected Campaigns and adds to the filter context
- Clears the Campaign filter
- Calculates the Average Open Rate in this modified context
If I call your table Data, this sort of pattern would work:
Open Rate Average =
AVERAGE ( Data[Open Rate] )
Open Rate Average for Same Mailing List as Selected Campaigns =
CALCULATE (
[Open Rate Average],
SUMMARIZE ( Data, Data[Mailing List] ),
ALL ( Data[Campaign] )
)
Notes:
- SUMMARIZE ( Data, Data[Mailing List] ) could be replaced with VALUES ( Data[Mailing List] ) since there is just a single table here, but SUMMARIZE would be needed if Mailing List was in a lookup table.
- The columns specified in SUMMARIZE determine the common attributes over which you want to calculate the average, so you can tweak this to whatever attributes you want.
- I cleared only the Campaign filter using ALL, so any other filters (date etc) are still applied. You could tweak this to clear more filters if you needed to.
Hope that helps as a starting point.
Cheers,
Owen :)
- Anonymous9 years agoNot applicable
It worked a treat!! Many thanks Owen!