cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
Helper II
Helper II

Transform a column with an 'If statement'

Hi,

 

I would like to modify a column without creating a new one. Basically I want to apply a rule:

 

If value >= 5, then 5.

 

Is there an easy way to do it without creating a new calculated field or measure?


Thanks

 

Jon

1 ACCEPTED SOLUTION

Accepted Solutions
Highlighted
Community Champion
Community Champion

Re: Transform a column with an 'If statement'

Hi @Ugarte335 ,

 

You will need to create this as a new column or a new measure.

 

Else filter this condition of value >= 5 at the source itself.

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

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

 

View solution in original post

3 REPLIES 3
Highlighted
Community Champion
Community Champion

Re: Transform a column with an 'If statement'

Hi @Ugarte335 ,

 

You will need to create this as a new column or a new measure.

 

Else filter this condition of value >= 5 at the source itself.

 


Regards,

Harsh Nathani


Appreciate with a Kudos!! (Click the Thumbs Up Button)

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

 

View solution in original post

Highlighted
Super User IV
Super User IV

Re: Transform a column with an 'If statement'

@Ugarte335 , May be power query you can edit the source script and try. Best is you create a new column only

 

if([value]>5,5,blank())



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
My Recent Blog -Week is not so Weak Connect on Linkedin

Proud to be a Super User!

Highlighted
Solution Sage
Solution Sage

Re: Transform a column with an 'If statement'

You can do that in power query. While importing the data, select "Add conditional column" option.

 

Add Conditional Column.png

The result will be as follows...

Add Conditional Column1.png

Then remove the field "Value" (Right-click, Remove) before applying the changes. Internally the power query generated automaticall will look like this.

 

let
    Source = Excel.Workbook(File.Contents("C:\Users\S\Documents\Book1.xlsx"), null, true),
    Sheet1_Sheet = Source{[Item="Sheet1",Kind="Sheet"]}[Data],
    #"Promoted Headers" = Table.PromoteHeaders(Sheet1_Sheet, [PromoteAllScalars=true]),
    #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"Item", type text}, {"Value", Int64.Type}}),
    #"Added Conditional Column" = Table.AddColumn(#"Changed Type", "Custom", each if [Value] >= 5 then 5 else [Value]),
    #"Removed Columns" = Table.RemoveColumns(#"Added Conditional Column",{"Value"})
in
    #"Removed Columns"

 

Helpful resources

Announcements
August 2020 Community Challenge: Can You Solve These?

August 2020 Community Challenge: Can You Solve These?

We're excited to announce our first cross-community 'Can You Solve These?' challenge!

July 2020 Community Highlights

July 2020 Community Highlights

Learn about the exciting things that happened in July.

Get Ready for Power BI Dev Camp

Get Ready for Power BI Dev Camp

We are thrilled to announce we will begin running a monthly webinar series named Power BI Dev Camp.

Power BI Desktop August 2020 Update

Power BI Desktop August 2020 Update

We have great updates this month! Click the link for the video with more info.

Top Solution Authors
Top Kudoed Authors