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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
S_JB
Resolver III
Resolver III

How to use the same value twice in an IF statement

Hi all,

 

In my dataset there is a field called "Availability" with values of 0 and 1. I want to create a new column which labels records with the value of 1 "available" then any instances with the values of either 0 and 1 "All".

I tried an IF statement to see if it would allow the usage of the same value twice (please see the logic below):

Availability =
IF(
'Table 1'[Availability ] IN { 1,0 },
"All",
IF(
'Table 1'[Availability] = 0,
"Unavailable"
))

 

My understanding of why this doesn't work is because the IF statement looks at the first line of the logic and will assign all records with a value of 0 and 1 to "All", so the second line will have no records left to allocate. If I reversed the order this would work in a similar manner and remove all 0 instances, only allocating instances with the value of 1 to "All".

 

Is there a way that I can tweak the IF statement to all me to use the same value twice? Or do I need to take a different approach?

 

Hopefully the above makes sense and you understand what I am trying to achieve!

1 ACCEPTED SOLUTION

Thanks for this suggestion @amitchandak 

 

Unfortunately this did not work and labelled all instances the same.

 

However, I managed to get around it with a simple solution. I created a column using the below logic:

 

Availability = IF('Table 1'[Availability] = 1,"Available","N/A")

 

I then put a filter on this slicer to remove "N/A" instances. The slicer has been defaulted to "Available" but if "Select all" is selected then this will show both "Available" and "Unavailable" instances.

 

Thanks again.

View solution in original post

2 REPLIES 2
amitchandak
Super User
Super User

@S_JB , I think you have to try a measure like

IF( hasonevalue('Table 1'[Availability]) , if( selectedValue('Table 1'[Availability]) = 0,"Unavailable", "Avaiable"),"All")

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks for this suggestion @amitchandak 

 

Unfortunately this did not work and labelled all instances the same.

 

However, I managed to get around it with a simple solution. I created a column using the below logic:

 

Availability = IF('Table 1'[Availability] = 1,"Available","N/A")

 

I then put a filter on this slicer to remove "N/A" instances. The slicer has been defaulted to "Available" but if "Select all" is selected then this will show both "Available" and "Unavailable" instances.

 

Thanks again.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

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

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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.