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
Mars3442
Helper I
Helper I

Replace only null value with 2 conditions

Hi everyone,

I want to ask a help for solving my problem

I have a table like this

Mars3442_0-1699443914474.png

I need to replace the null value with these conditional :

Purchase number= null, Purchase 2 number = null, the status = No Data

Without replace the cell that have been filled

 

My expectation table like this

Mars3442_1-1699444004837.png

What M Code I should write to get my expectations?

 

Please help me to solve this problem

 

Thank you..

2 ACCEPTED SOLUTIONS
mlsx4
Super User
Super User

Hi @Mars3442 

 

Try this 

= Table.ReplaceValue(#"PreviousStepName",null,each if [Purchase number]=null and [Purchase 2 number]=null then "No data" else null,Replacer.ReplaceValue,{"Status"})

View solution in original post

Have you replaced the name of the previous step between ""? And the column name is "Status"?

For me, it's working perfectly.

Check also that previous line ends with a ",":

#previousStep=.........(.....),

#replaceNull= Table.ReplaceValue...

View solution in original post

5 REPLIES 5
Mars3442
Helper I
Helper I

Oke it works just now

Thank you!

I'm glad it works now!

You're welcome

mlsx4
Super User
Super User

Hi @Mars3442 

 

Try this 

= Table.ReplaceValue(#"PreviousStepName",null,each if [Purchase number]=null and [Purchase 2 number]=null then "No data" else null,Replacer.ReplaceValue,{"Status"})

It returns

Expression.SyntaxError: Token Literal expected.

Table.ReplaceValue(#"PreviousStepName",
------> ^
null,each if [Purchase number]=null and [Purchase 2 number]=null then "No data" else null,Replacer.ReplaceValue,{"Status"}) 

what should I do?

Have you replaced the name of the previous step between ""? And the column name is "Status"?

For me, it's working perfectly.

Check also that previous line ends with a ",":

#previousStep=.........(.....),

#replaceNull= Table.ReplaceValue...

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.

Top Solution Authors
Top Kudoed Authors