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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Stuznet
Helper V
Helper V

How to turn Lookupvalue in to Switch Function

Hi all,

 

On the Excel I have 2 Worksheets.

Table 1

 

If Table1[Var] match the Table2[Min] then give me the Percentage

Is it possible to elimnate index/lookup table and use the Switch function? If yes, How do I turn this Index function into a Switch Function? 

 

=INDEX(Table2[Percentage],MATCH([@Var],Table2[Min],1))

 

2018-10-01_12-05-53.png

 

Lookup Table (Table2)

 

2018-10-01_12-09-47.png

 

 Thanks you 🙂 

 

 

 

2 ACCEPTED SOLUTIONS
v-frfei-msft
Community Support
Community Support

Hi @Stuznet,

 

Here we can use the IF function to create a calculated column to work on it.

 

Column = 
IF (
    Table1[var] > -1000
        && Table1[var] < -0.25,
    "<(25%)",
    IF (
        Table1[var] > -0.25
            && Table1[var] < -0.1,
        "(25%) - (10%)",
        IF (
            Table1[var] > -0.1
                && Table1[var] < -0.03,
            "(10%)-(3%)",
            IF (
                Table1[var] > -0.03
                    && Table1[var] < 0.03,
                "(3%)-3%",
                IF (
                    Table1[var] > 0.03
                        && Table1[var] < 0.1,
                    "3%-10%",
                    IF (
                        Table1[var] > 0.1
                            && Table1[var] < 0.25,
                        "10%-25%",
                        IF ( Table1[var] > 0.25, ">25%" )
                    )
                )
            )
        )
    )
)

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

HI @Stuznet @v-frfei-msft

 

This formula will achieve the same desired result 🙂

Column 2 = 
MINX (
    TOPN ( 1, FILTER ( Table2, Table1[var] > Table2[Min] ), [Min], DESC ),
    [Percentage]
)

swithee.png


Regards
Zubair

Please try my custom visuals

View solution in original post

3 REPLIES 3
v-frfei-msft
Community Support
Community Support

Hi @Stuznet,

 

Here we can use the IF function to create a calculated column to work on it.

 

Column = 
IF (
    Table1[var] > -1000
        && Table1[var] < -0.25,
    "<(25%)",
    IF (
        Table1[var] > -0.25
            && Table1[var] < -0.1,
        "(25%) - (10%)",
        IF (
            Table1[var] > -0.1
                && Table1[var] < -0.03,
            "(10%)-(3%)",
            IF (
                Table1[var] > -0.03
                    && Table1[var] < 0.03,
                "(3%)-3%",
                IF (
                    Table1[var] > 0.03
                        && Table1[var] < 0.1,
                    "3%-10%",
                    IF (
                        Table1[var] > 0.1
                            && Table1[var] < 0.25,
                        "10%-25%",
                        IF ( Table1[var] > 0.25, ">25%" )
                    )
                )
            )
        )
    )
)

Capture.PNG

 

For more details, please check the pbix as attached.

 

Regards,

Frank

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

HI @Stuznet @v-frfei-msft

 

This formula will achieve the same desired result 🙂

Column 2 = 
MINX (
    TOPN ( 1, FILTER ( Table2, Table1[var] > Table2[Min] ), [Min], DESC ),
    [Percentage]
)

swithee.png


Regards
Zubair

Please try my custom visuals

@Zubair_Muhammad@v-frfei-msft. Thank you so much, I accepted both solutions. It Worked!! 🙂 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.