Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Help creating a classifier from columns using RANKX

Hello,

I am currently trying to create a custom column in Power BI to classify email campaigns based on certain criteria. The column is called "CRITERIO" and I am using the SWITCH function to assign values to each campaign based on its name and the number of emails sent.

Here is the formula I am using:

 

cokeverdejo_0-1678374214601.png

 

 

The formula is supposed to assign values of "AURIS" or "TEST" to campaigns whose names contain those words, and "TOP 5", "TOP 6-10", or "TOP 11-15" to campaigns whose email volumes rank within those thresholds. All other campaigns should be assigned a value of "OTHER".

Here's and data's example:

 

RECIPIENT_IDEVENT_TYPENOMBREEMAIL
607227625501SentLPRxxxxxxx@gmail.com
579440932400Open[AURIS] SIN CONTACTO APIyyyyyy@icloud.com
579440932952Sent[TEST] LISTO PARA RETIRO APIzzzzzzz@hotmail.com
579440957813SentENCUESTAaaaaaaa@email.com
618127727620SentPOLLbbbbb@email.com
565900248891SentWELCOMEccccccc@email.com

 

Data Base Sample 

 

However, I am running into a few issues. First, the formula is not correctly filtering the "TOP 5" campaigns, and is instead assigning that value to all campaigns that are not "AURIS" or "TEST". Second, occasionally the formula is creating a circular dependency that prevents me from using the "COUNT" function instead "DISTINCTCOUNT".

 

I have tried a few different variations of the formula, including using COUNTROWS instead of DISTINCTCOUNT, and using a different column as the first argument of the RANKX function, but I have not been able to resolve the issues.

 

Any help or suggestions would be greatly appreciated. Thank you!

3 REPLIES 3
lbendlin
Super User
Super User

Please provide sample data that covers all your scenarios.

Anonymous
Not applicable

I just added a sample to use!

Please provide sample data that covers your issue or question completely.
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.