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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
setis
Post Partisan
Post Partisan

IF and SELECTEDVALUE with multiple conditions

Dear experts,

I have the following issue. 
I have a slicer with several elements. When 2 specific elements are selected, I want a specific calculation and if they are not, I want another one. 

 

I'm trying:

 

IF(
        SELECTEDVALUE(G_L Entry'[BU]) = "B2B"||
        SELECTEDVALUE(G_L Entry'[BU]) = "B2I";
        [Revenue] * [ExchRateCurrency];
        "" )

 

Another way that it's not working either: 

IF(
OR(  
        SELECTEDVALUE(G_L Entry'[BU]) = "B2B";
        SELECTEDVALUE(G_L Entry'[BU]) = "B2I");
        [Revenue] * [ExchRateCurrency];
        "" )

 

Could somebody help, please?

 

1 ACCEPTED SOLUTION
tex628
Community Champion
Community Champion

Sorry i was abit to quick there! 🙂 

IF(
AND(
        FIRSTNONBLANK(G_L Entry'[BU];G_L Entry'[BU]) = "B2B" ||
        FIRSTNONBLANK(G_L Entry'[BU];G_L Entry'[BU]) = "B2I" ;
        LASTNONBLANK(G_L Entry'[BU];G_L Entry'[BU]) = "B2B" ||
        LASTNONBLANK(G_L Entry'[BU];G_L Entry'[BU]) = "B2I" ) ;
        [Revenue] * [ExchRateCurrency];
        "" )

Connect on LinkedIn

View solution in original post

6 REPLIES 6
tex628
Community Champion
Community Champion

 While there is more than 1 value in G_L Entry [BU] selectedvalue() will always return blank(). That is why your measure is not working. You need to use FIRSTNONBLANK() and LASTNONBLANK() to find the two values. 

IF(
AND(
        FIRSTNONBLANK(G_L Entry'[BU]) = "B2B" ||
        FIRSTNONBLANK(G_L Entry'[BU]) = "B2I" ;
        LASTNONBLANK(G_L Entry'[BU]) = "B2B" ||
        LASTNONBLANK(G_L Entry'[BU]) = "B2I" ) ;
        [Revenue] * [ExchRateCurrency];
        "" )


Br,
J


Connect on LinkedIn

@MartynRamsden I am getting blanks when those are selected.


@tex628 Sounds logical. Thanks. 
I think that I'm missing someting. I am getting the error "Too few arguments were passes to the FIRSTNONBLANK function. The minimum argument count for the function is 2."

tex628
Community Champion
Community Champion

Sorry i was abit to quick there! 🙂 

IF(
AND(
        FIRSTNONBLANK(G_L Entry'[BU];G_L Entry'[BU]) = "B2B" ||
        FIRSTNONBLANK(G_L Entry'[BU];G_L Entry'[BU]) = "B2I" ;
        LASTNONBLANK(G_L Entry'[BU];G_L Entry'[BU]) = "B2B" ||
        LASTNONBLANK(G_L Entry'[BU];G_L Entry'[BU]) = "B2I" ) ;
        [Revenue] * [ExchRateCurrency];
        "" )

Connect on LinkedIn

What if you want to do the same thing for 3 values ?

FIRSTNONBLANK and LASTNONBLANK would not be enough.

 

Do you know how I could proceed ?

 

Cheers,

@tex628 Perfect. It works. Thank you so much!

@MartynRamsden Thanks a lot for your help too. 

MartynRamsden
Solution Sage
Solution Sage

Hi @setis 

 

Both expressions look ok to me.  What result are you seeing?

 

Have you tried IN?

Measure = 
IF(
    SELECTEDVALUE( G_L Entry'[BU] ) IN { "B2B", "B2I" };
    [Revenue] * [ExchRateCurrency];
    ""
)

 

Best regards,
Martyn


If I answered your question, please help others by accepting it as a solution.

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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