Forum Discussion
Rank measure help
- 1 year ago
Apologies for the delayed response. I didn't find a solution to this in the end and had to try a different approach instead.
Hi ST2022 ,
To rank emails based on their open rate within a selected date filter period (such as "Previous week", "Last 7 days", etc.), you can create a DAX measure that first filters the email data to only include the dates from the selected filter, then calculates the open rate per email name, and finally ranks the emails based on this open rate. The key is to aggregate total opens and total deliveries for each email name within the selected period and then compute the open rate as a percentage before applying the rank.
Here's a DAX measure that achieves this:
Email Open Rate Rank =
VAR SelectedDates =
VALUES('Date filter table'[Date])
VAR FilteredEmails =
CALCULATETABLE(
'Email table',
'Email table'[Date sent] IN SelectedDates
)
VAR OpenRateTable =
ADDCOLUMNS(
SUMMARIZE(FilteredEmails, 'Email table'[Email name]),
"TotalDelivered", CALCULATE(SUM('Email table'[Total Delivered]), 'Email table'[Date sent] IN SelectedDates),
"TotalOpened", CALCULATE(SUM('Email table'[Total Opened]), 'Email table'[Date sent] IN SelectedDates)
)
VAR WithOpenRate =
ADDCOLUMNS(
OpenRateTable,
"OpenRate", DIVIDE([TotalOpened], [TotalDelivered])
)
VAR CurrentEmail = SELECTEDVALUE('Email table'[Email name])
VAR CurrentOpenRate =
CALCULATE(
DIVIDE(SUM('Email table'[Total Opened]), SUM('Email table'[Total Delivered])),
'Email table'[Date sent] IN SelectedDates,
'Email table'[Email name] = CurrentEmail
)
RETURN
RANKX(
WithOpenRate,
[OpenRate],
CurrentOpenRate,
DESC,
DENSE
)
This measure ensures that the open rate is calculated only using the email records from the selected time window and then ranks each email accordingly. It handles multiple sends of the same email by aggregating their opens and deliveries. The DENSE option ensures that ranks increase sequentially without gaps.
Best regards,
Hi DataNinja777
Thanks so much for taking the time to look at this and providing this measure.
I gave that a try, but it returns a rank of 1 for all my emails. I had the same result with everything else I've tried and can't figure out why it's returning a 1 for everything.
- Anonymous1 year agoNot applicable
Hi ST2022 ,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. If the issue still persists, it's most likely related to how the RANKX function is evaluating the open rates.
Thank you.