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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Anonymous
Not applicable

Multiple IF statements in my Return

Good Afternoon,

In trying to add multiple if statements in my return, I have failed:

jodyfox61_0-1687367048207.png

 

I also need to add another IF statement for blanks when my company session returns no values and that ugly:

jodyfox61_1-1687367159533.png

 

shows up.

 

Essentially:   ISBLANK(divide_),0,divide_

 

I have tried so many variations:

Trying SWITCH – Couldn’t get it to work

% of Total 1 =

VAR divide_ = DIVIDE(B1[Calculate Total Sessions Column],COUNT(B1[properties.session_number])*100)

//VAR onefilter_ = HASONEFILTER(B1[Company])

RETURN

SWITCH(

     ISFILTERED(B1[Company]),divide_,0

     ISBLANK(divide_),0,divide_

)

 

 

Failed

% of Total 1 =

VAR divide_ = DIVIDE(B1[Calculate Total Sessions Column],COUNT(B1[properties.session_number])*100)

//VAR onefilter_ = HASONEFILTER(B1[Company])

RETURN

IF (

    ISFILTERED(B1[Company]),divide_,0

ELSE

    ISBLANK(divide_),0,divide_

)

 

% of Total 1 =

VAR divide_ = DIVIDE(B1[Calculate Total Sessions Column],COUNT(B1[properties.session_number])*100)

//VAR onefilter_ = HASONEFILTER(B1[Company])

RETURN

IF (

    ISFILTERED(B1[Company]),divide_,0 || ISBLANK(divide_),0,divide_

    )

 

% of Total 1 =

VAR divide_ = DIVIDE(B1[Calculate Total Sessions Column],COUNT(B1[properties.session_number])*100)

//VAR onefilter_ = HASONEFILTER(B1[Company])

RETURN

IF (

    ISFILTERED(B1[Company]),divide_,0 && ISBLANK(divide_),0,divide_

    )

 

ALL FAILURES!

 

CONCLUSION

I need to incorporate this:

ISBLANK(divide_),0,divide_

 

into this:

 

% of Total 1 =
VAR divide_ = DIVIDE(B1[Calculate Total Sessions Column],COUNT(B1[properties.session_number])*100)
//VAR onefilter_ = HASONEFILTER(B1[Company])
RETURN
IF (
    ISFILTERED(B1[Company]),divide_,0
)
 
Thank you in advance.
3 REPLIES 3
Anonymous
Not applicable

I'm sorry, I just read your reply all the way through. I am going to attempt the 3 measures now.

Alex_Sawdo
Resolver II
Resolver II

I guess I'm a little confused as to what you're initially trying to calculate here. If you're trying to get a % of total calculation, there is a much better way of calculating this number out with 3 measures. For the numerator, you'd have your regular calculation such as 

CALCULATE(
 COUNT(
  SomeTable[SomeValue]
 )
)

Then for the denominator, you could use this calculation:

CALCULATE
 COUNT(
  SomeTable[SomeValue]
 ),
 REMOVEFILTERS(SomeTable)
)

With the denominator, all values from the inital table will be calculated for the denominator. Then, you can have a third calculation which divides the numerator by the denominator without needing any IF or SWITCH statements. In addition, DIVIDE does offer an alternative result that you can put in 0 for cases where the evaluation returns blank. 

Anonymous
Not applicable

Hi Alex,

Thank you so much for responding. 

The initial calcuation is already done in the    divide_    in this "% of Total 1" measure.

I am trying to accomodate for some filter issues I have run up against.

 

If I select a company in the filter that has "Coaching" data, everything is great.

 

But I found that if nothing was selected it was displaying 01.00% (I couldn't figure out how to fix that in the data) :

jodyfox61_0-1687380226432.png

So I came up with this that worked for that issue:

 

IF (
  ISFILTERED(B1[Company]),divide_,0
)
 
jodyfox61_1-1687380550902.png

 

However, I still have the issue with this Blank.. that comes up if I chose a company in the filter that has no data for coaching sessions behind it:

jodyfox61_2-1687380821659.png

 

So I was trying to figure out how to also use this code to accomodate for that:

IF(
  ISBLANK(divide_),0,divide_
)

I have used ISBLANK in other areas but never had 2 issues with one visual.

jodyfox61_3-1687381173741.png

Thank you again,

 

 

 

 

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

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.

Top Solution Authors
Top Kudoed Authors