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

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
Anonymous
Not applicable

Transform By Dividing Based On Another Column Conditionally

Hello there,

 

Can someone help me on spotting the problem with this script:

 

= Table.TransformColumns(#"Grouped Rows2", {{"Tenure", each if [AD Account]="Shams, Magdoulin" then _ / 2 else _, type number}})

 

I get the below error

 

Expression.Error: We cannot apply field access to the type Duration.
Details:
Value=335.00:00:00
Key=AD Account

 

Although I have tried as a test to divide the column Tenure by 2 directly and it worked without errors, so, why when I set a condition based on another column value it does not accept?

1 ACCEPTED SOLUTION

Correct. Table.TransformColumns only transforms columns individually. You can't cross-reference other columns in the transformation definition.

 

The easiest method is usually to define a new custom column instead of transforming an existing one since you can reference multiple columns that way.

View solution in original post

3 REPLIES 3
wdx223_Daniel
Community Champion
Community Champion

the function of Table.TransformColumns can not get the value of other columns, you can try Table.ReplaceValue

= Table.RepaceValue(#"Grouped Rows2",each [AD Account],"",(x,y,z)=x/(1+Byte.From(y="hams, Magdoulin)),{"Tenure"})

Anonymous
Not applicable

So, this is something I cannot tweak the below to get output?

 

= Table.TransformColumns(#"Grouped Rows2", {{"Tenure", each _ / [Count], type number}})

 

Correct. Table.TransformColumns only transforms columns individually. You can't cross-reference other columns in the transformation definition.

 

The easiest method is usually to define a new custom column instead of transforming an existing one since you can reference multiple columns that way.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.