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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
azaterol
Helper V
Helper V

Delete text when measure shows a number

Hello everyone,

 

I have a measure with:

 

 

last sales in weeks = LASTNONBLANK('Date'[Date],[Sales])

 

 

Here I can see when the customer last ordered in weeks.

So far so good!

 

This i now what I have:

azaterol_2-1677854240935.png

 


I also have a text field column with a "J" in it. If last sales in weeks appears a 0, I want the "J" in the text field to be deleted. 

 

Is there a way to delete the J with a measure if the measure last sales in weeks show 0?

 

This is what I want:

azaterol_3-1677854300566.png

 

 

Thank you for help. 

 

 

6 REPLIES 6
AndrewPF
Helper V
Helper V

Edited reply (forgot the function element, bsheffer, thank you): 

You also need the table name if you are creating a measure from a column. Type: 

NEW MEASURE = if (LASTNONBLANK('Date'[Date],[Sales]) = 0, "", FUNCTION('TABLE NAME'[VARIABLE NAME]))

where FUNCTION is, for example, MIN or MAX.

Note that the table names are surrounded by single apostrophes. 

AndrewPF
Helper V
Helper V

You could create a new measure to put into your table: 

if (LASTNONBLANK('Date'[Date],[Sales]) = 0, "", [INSERT NAME OF TEXT VARIABLE HERE])

@AndrewPF  good idea, but the problem here is the text variable which contains the "J" is a column from a SQL Database not a measure. 


Your code dont work for this.

bsheffer
Continued Contributor
Continued Contributor

you can't blank a value in a visual otherwise.  The measure is correct.  replace "text variable" with your column value.

@bsheffer  

azaterol_0-1677859311914.png

 

i replaced. It says: Cannot find name 'Leer_Ja_Nein' <- this is what I named my column value. 

 

The hints from Power BI only show me measures no columns!

azaterol_1-1677859631187.png

 

If this dont work, how can i convert my column into a measure, so that I can use this code?

 

bsheffer
Continued Contributor
Continued Contributor

measures aggregate so you have to wrap your column in a function like min or max

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.