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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

Reply
moomarine
Helper II
Helper II

Replace all value in multiple columns that are greater than 0 with text value

Hi All

 

How do i amend the below to change all values greater than zero to "Completed" and any that are zero to "Not Completed" in multiple columns? The data is basically multiple course completions count per resource.

 

At the moment i have the below formula to find "Completed" and a separate formula string/step to find the zeros which = "Not Completed" but i am finding a lot of rows have 2 or 3 etc (multiple completions of the same course)

 

= Table.ReplaceValue(#"Changed Type",0,"Not Completed",Replacer.ReplaceValue,{"Course 1", "Course 2", "Course 3", "Course 4", "Course 5"})

 

= Table.ReplaceValue(#"Replaced Value2",1,"Completed",Replacer.ReplaceValue,{"Course 1", "Course 2", "Course 3", "Course 4", "Course 5"})

5 REPLIES 5
V-pazhen-msft
Community Support
Community Support

@moomarine 

 

For a workaround, you can only replace 0 with "Not Complete": hold on shift selected the most left and the most right column to select all columns,  change the data type to text, then use replace function as below, that only replaces 0 with Not complete.

V-pazhen-msft_1-1618472552809.png

 

In addition, you may follow the below link that creates a column name list then replace value for the whole table.

Power Query - Replace values for whole table - Hat Full of Data

 


Paul Zheng _ Community Support Team
If this post helps, please Accept it as the solution to help the other members find it more quickly.

 

 

 

AlexisOlson
Super User
Super User

Table.TransformColumns works better here.

 

= Table.TransformColumns(#"Changed Type",
{
    {"Course 1", each if _ > 0 then "Completed" else "Not Completed", type text},
    {"Course 2", each if _ > 0 then "Completed" else "Not Completed", type text},
    {"Course 3", each if _ > 0 then "Completed" else "Not Completed", type text},
    {"Course 4", each if _ > 0 then "Completed" else "Not Completed", type text},
    {"Course 5", each if _ > 0 then "Completed" else "Not Completed", type text}
})

 

 

 

Hi, thanks for your response, only issue with this there are over 100 different courses so would be hard going typing this out. Is there any other way?

Looks good i will give it a go later on and let you know how it goes.

Helpful resources

Announcements
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors