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
LyonsBI_BRL
Helper III
Helper III

Nested IF Statement - Not Returning all Conditions

I'm running into a problem when running my nested IF statement.

 

If([value.FollowersonTwitter]<=500, "Less than 500",
IF([value.FollowersonTwitter]>=1000, "1000",
IF([value.FollowersonTwitter]>=5000, "5000+",
IF([value.FollowersonTwitter]>=10000, "10,000+", "No Followers"))))

 

Though when I run it I'm not getting any results for the rows that have 5000 or 10000 followers. What am I missing here?

 

LyonsBI_BRL_3-1621495774507.png

 

Thanks!

 

 

1 ACCEPTED SOLUTION
selimovd
Super User
Super User

Hey @LyonsBI_BRL ,

 

when you have 6000 followers the criteria >=1000 gives back a true and the other options are not checked.

You can either change the order, so that the biggest numbers are checked first:

 

IF([value.FollowersonTwitter]>=10000, "10,000+",
IF([value.FollowersonTwitter]>=5000, "5000+",
IF([value.FollowersonTwitter]>=1000, "1000",
If([value.FollowersonTwitter]<=500, "Less than 500", "No Followers"))))

 

 

Or you have to add a second citeria:

 

If([value.FollowersonTwitter]<=500, "Less than 500",
IF([value.FollowersonTwitter]>=1000 && [value.FollowersonTwitter]<5000, "1000",
IF([value.FollowersonTwitter]>=5000 && [value.FollowersonTwitter]<10000, "5000+",
IF([value.FollowersonTwitter]>=10000, "10,000+", "No Followers"))))

 

 

Also I would recommend to check out the usage of SWITCH(TRUE) as it's a lot clearer than nested ifs:

https://powerpivotpro.com/2015/03/the-diabolical-genius-of-switch-true/

 

myCalculatedColumn =
SWITCH(
    TRUE(),
    [value.FollowersonTwitter] >= 10000, "10,000+",
    [value.FollowersonTwitter] >= 5000, "5000+",
    [value.FollowersonTwitter] >= 1000, "1000",
    [value.FollowersonTwitter] <= 500, "Less than 500",
    "No Followers"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

View solution in original post

3 REPLIES 3
selimovd
Super User
Super User

Hey @LyonsBI_BRL ,

 

when you have 6000 followers the criteria >=1000 gives back a true and the other options are not checked.

You can either change the order, so that the biggest numbers are checked first:

 

IF([value.FollowersonTwitter]>=10000, "10,000+",
IF([value.FollowersonTwitter]>=5000, "5000+",
IF([value.FollowersonTwitter]>=1000, "1000",
If([value.FollowersonTwitter]<=500, "Less than 500", "No Followers"))))

 

 

Or you have to add a second citeria:

 

If([value.FollowersonTwitter]<=500, "Less than 500",
IF([value.FollowersonTwitter]>=1000 && [value.FollowersonTwitter]<5000, "1000",
IF([value.FollowersonTwitter]>=5000 && [value.FollowersonTwitter]<10000, "5000+",
IF([value.FollowersonTwitter]>=10000, "10,000+", "No Followers"))))

 

 

Also I would recommend to check out the usage of SWITCH(TRUE) as it's a lot clearer than nested ifs:

https://powerpivotpro.com/2015/03/the-diabolical-genius-of-switch-true/

 

myCalculatedColumn =
SWITCH(
    TRUE(),
    [value.FollowersonTwitter] >= 10000, "10,000+",
    [value.FollowersonTwitter] >= 5000, "5000+",
    [value.FollowersonTwitter] >= 1000, "1000",
    [value.FollowersonTwitter] <= 500, "Less than 500",
    "No Followers"
)

 

If you need any help please let me know.
If I answered your question I would be happy if you could mark my post as a solution ✔️ and give it a thumbs up 👍
 
Best regards
Denis
 

Worked perfectly! Like I said I knew I was missing something here!

 

Thank you again! 😀

@LyonsBI_BRL I'm happy it worked. Yes, that are usually the annoying parts, when you don't see it and search at the wrong spot.

 

Best regards

Denis

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.