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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
DW868990
Helper IV
Helper IV

Change column values based on parameter

Hi, 

 

I have a true/false parameter within power query. 

 

Now within my table I have a column which is the name of each products. 

DW868990_0-1695298625850.png

But when I have the parameter set as TRUE, I require the column to then show as:

DW868990_1-1695298682997.png

Is there a way to achieve this?

Thanks





1 ACCEPTED SOLUTION
v-tangjie-msft
Community Support
Community Support

Hi @DW868990 ,

 

In power query, click "Advanced Editor" and copy and paste the following code.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElVitWJVgpITUwsgrGAjFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Replaced Value" = Table.ReplaceValue(#"Added Index",each [Column1],   each if Parameter1=true then Text.Combine({"Prod ",Text.From([Index], "en-US")}, "") else [Column1],Replacer.ReplaceValue,{"Column1"})
in
    #"Replaced Value"

 

vtangjiemsft_0-1695632449459.pngvtangjiemsft_1-1695632458735.pngvtangjiemsft_2-1695632470979.pngvtangjiemsft_3-1695632479068.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

View solution in original post

3 REPLIES 3
v-tangjie-msft
Community Support
Community Support

Hi @DW868990 ,

 

In power query, click "Advanced Editor" and copy and paste the following code.

 

let
    Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WciwoyElVitWJVgpITUwsgrGAjFgA", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [Column1 = _t]),
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Column1", type text}}),
    #"Added Index" = Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type),
    #"Replaced Value" = Table.ReplaceValue(#"Added Index",each [Column1],   each if Parameter1=true then Text.Combine({"Prod ",Text.From([Index], "en-US")}, "") else [Column1],Replacer.ReplaceValue,{"Column1"})
in
    #"Replaced Value"

 

vtangjiemsft_0-1695632449459.pngvtangjiemsft_1-1695632458735.pngvtangjiemsft_2-1695632470979.pngvtangjiemsft_3-1695632479068.png

Best Regards,

Neeko Tang

If this post  helps, then please consider Accept it as the solution  to help the other members find it more quickly. 

 

Idrissshatila
Super User
Super User

HEllo @DW868990 ,

 

Try acheiving this using field parameters https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters

 

If I answered your question, please mark my post as solution, Appreciate your Kudos 👍

Follow me on Linkedin
Vote for my Community Mobile App Idea 💡



Did I answer your question? Mark my post as a solution! Appreciate your Kudos
Follow me on LinkedIn linkedIn
Vote for my Community Mobile App Idea

Proud to be a Super User!




ah sorry, I wasnt clear, the parameter is a parameter within the power query editor, not a field parameter. 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.