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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
astano05
Helper III
Helper III

Measure to Display 0 if blank and 1 if not blank

I want to create a measure to display 0 if a specified field for a record is blank, and 1 if it is not blank. I want to show this for each record. I think this might be better as a column, but if I can do it as a measure that is preferred as I dont have direct edit access to the model to add a column. 

 

I tried the below, but it tells me the resources exceeded

if(isblank(SELECTEDVALUE(Contacts[Email])),0,1)
4 REPLIES 4
Sahir_Maharaj
Super User
Super User

Hello @astano05,

 

The SELECTEDVALUE method expects a scalar result to be returned, however it is being used in a context that produces many values, which is why you are receiving a resource exceeded error. You can use the IF function in its place to get around this problem.

 

Can you try this: 

 

Measure =
IF(
    ISBLANK(MAX(Contacts[Email])),
    0,
    1
)

 

This measurement determines if the Email column's maximum value in the current context is blank. The measure returns 0 if it is, while returning 1 otherwise.


Did I answer your question? Mark my post as a solution, this will help others!

If my response(s) assisted you in any way, don't forget to drop me a "Kudos" 🙂

Kind Regards,
Sahir Maharaj
Data Scientist | Data Engineer | Data Analyst | AI Engineer
P.S. Want me to build your Power BI solution?
➤ Lets connect on LinkedIn: Join my network of 13K+ professionals
➤ Join my free newsletter: Data Driven: From 0 to 100
➤ Website: https://sahirmaharaj.com
➤ Email: sahir@sahirmaharaj.com
➤ Want me to build your Power BI solution? Lets chat about how I can assist!
➤ Join my Medium community of 30K readers! Sharing my knowledge about data science and artificial intelligence
➤ Explore my latest project (350K+ views): Wordlit.net
➤ 100+ FREE Power BI Themes: Download Now
LinkedIn Top Voice in Artificial Intelligence, Data Science and Machine Learning
DanielGarcia
Advocate I
Advocate I

Good nigth man, 
So, to do this the best way is in a column because do you need a value to every line. 

 

Try two ways:

Column

Way1 = if(Contacts[Email] is blank, 0,1)

measure
Way2 = 
     var email = SELECTEDVALUE(Contacts[Email])
     var test = if(email is blank,0,1)
      return test

 

Please tell us the result!

Thank you for responding! 

 

The measure doesn't give me the result I'm looking for, it returns a 0 for every value.

Good morning, so, the value Contacts[Email] is blank in all rows? 

Can you send a print or a video?

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.