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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Anonymous
Not applicable

Change Blanks to Zero in Table

Hi there,

 

I have a table carrying integers which contains blanks. Ideally I would prefer these blank values to contain 0. Can I create a measure that acheives this? 

 

Thanks 

 

 

2 ACCEPTED SOLUTIONS
Anonymous
Not applicable

I found a quick and easy solution here if anyone is interested: 

 

https://community.powerbi.com/t5/Desktop/show-items-with-no-data-as-0-instead-of-blanks/td-p/113160

 

See Seans's solution specifically. It's very similar to one of amitchandak's reccomendations. 

 

Kind regards

View solution in original post

Hi  @Anonymous ,

 

Yes,it is also supported if the value is a measure,see below:

v-kelly-msft_0-1615887727229.png

If your issue is solved,could you pls mark the reply as answered to let more people find the solution?

Much appreciated.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

View solution in original post

6 REPLIES 6
v-kelly-msft
Community Support
Community Support

Hi  @Anonymous ,

 

If you wanna replace all the blanks in a table into 0,you'd better do it in query editor using below M codes:

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMlLSUTJUitWJVgIyjMAMYyALJmIMZpgAWaZKsbEA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t, Column2 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", Int64.Type}, {"Column2", Int64.Type}}),
    #"Replaced Value1" = Table.ReplaceValue(#"Changed Type",null,0,Replacer.ReplaceValue,Table.ColumnNames(#"Changed Type"))
in
    #"Replaced Value1"

And you will see:

v-kelly-msft_0-1615794937392.png

Using measure can only replace the values in a certain column,see below:

Measure = IF(ISBLANK(MAX('Table (2)'[Column1])),0,MAX('Table (2)'[Column1]))

v-kelly-msft_1-1615795307229.png

For the related .pbix file,pls see attached.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

Anonymous
Not applicable

Hey Kelly, appreciate the help.

 

I tried using your M Code solution but it makes all my visuals go blank.

 

In regards to 

Measure = IF(ISBLANK(MAX('Table (2)'[Column1])),0,MAX('Table (2)'[Column1]))

Will that measure work if the data in my visual is also a measure?  so instead of 'Table (2)'[Columnx] its

'Table (2)'[Measurex]

 

Thanks

Anonymous
Not applicable

I found a quick and easy solution here if anyone is interested: 

 

https://community.powerbi.com/t5/Desktop/show-items-with-no-data-as-0-instead-of-blanks/td-p/113160

 

See Seans's solution specifically. It's very similar to one of amitchandak's reccomendations. 

 

Kind regards

Hi  @Anonymous ,

 

Yes,it is also supported if the value is a measure,see below:

v-kelly-msft_0-1615887727229.png

If your issue is solved,could you pls mark the reply as answered to let more people find the solution?

Much appreciated.

 

Best Regards,
Kelly

Did I answer your question? Mark my post as a solution!

amitchandak
Super User
Super User

@Anonymous , Add +0 , but will create a complete left join 

 

New measure = [measure] +0

 

 

Another example of controlled +0

 


0 between range //only between range


Measure = var _1= SUM(Opportunity[Opportunity count]) +0
var _min = minx(ALLSELECTED('Calendar'), 'Calendar'[Date])
var _max = maxx(ALLSELECTED('Calendar'), 'Calendar'[Date])
return
CALCULATE(if(max('Calendar'[Date]) <_min || max('Calendar'[Date]) >_max , BLANK(), _1))

 

Anonymous
Not applicable

HI there,

 

I dont know how to embed this solution into my power bi report. 

 

 

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.