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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Vijay08V
Helper II
Helper II

DAX to map values for range of numbers

Hi,

 

I need some help in writing a DAX to map the values based on range of number. I have a main table A with Ranks and another table B with Rating and rank. Below are the sample tables. Here the required output is rank 1 should be mapped as "Far Exceed". Between Rank 2-3 , it should be mapped as "Exceed" and between rank 4-9 should be mapped as "Meet". In Excel its simple using the Vlookup function with approximate match. Any help how to do this in Power BI ?

Table A :    

RankRating
1Far Exceed
2Exceed
3Exceed
4Meet
5Meet
6Meet
7Meet
8Meet
9Meet
10Doesnot

 

Table B :

RankRating

1Far Exceed
2Exceed
4Meet
10Doesnot

 

3 REPLIES 3
v-tianyich-msft
Community Support
Community Support

Hi @Vijay08V ,

 

You can simply use the minimum value aggregation that comes with Power BI and you can check the results as follows:

vtianyichmsft_0-1698397451737.png

 

Then I updated the data:

vtianyichmsft_1-1698397451738.png

 

 

 

 

Hope it helps!

 

Best regards,
Community Support Team_ Scott Chang

 

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

Vijay08V
Helper II
Helper II

Hi @Sahir_Maharaj ,

 

Thanks for your response but here the table B values will not be static. It would change. Table B values change based on the Headcount value. Say for example if the HC is 58 then the ranking would as below table. In excel either using lookup or vlookup with approximate match I was able to do it but not sure how to do that in Power Bi.Pic 1.jpg

Sahir_Maharaj
Super User
Super User

Hello @Vijay08V,

 

Can you please try this DAX:

Mapped Rating = 
VAR CurrentRank = 'Table A'[Rank]
RETURN
    SWITCH(TRUE(),
        CurrentRank = 1, "Far Exceed",
        CurrentRank >= 2 && CurrentRank <= 3, "Exceed",
        CurrentRank >= 4 && CurrentRank <= 9, "Meet",
        CurrentRank = 10, "Doesnot",
        BLANK()
    )

Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 15K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.