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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Mic1979
Post Partisan
Post Partisan

Dynamic transformation and rounding

Hello all,

 

I need to change the type only on the columns with  $ in the header.

 

I have the following code:

 

TransformDollars = Table.TransformColumnTypes(
renameColumns,
List.Transform(
List.Select(Table.ColumnNames(renameColumns), each Text.Contains(_, "$")), each {_, Number.Type})
),

Dollars_Columns_Selected = List.Select(Table.ColumnNames(TransformDollars), each Text.Contains(_, "$")),

RoundDollars = Table.TransformColumns (
TransformDollars,
List.Transform (
Dollars_Columns_Selected,
each {_, Number.Round(_, 3), type number}))

in RoundDollars

 

but I get this error:

Mic1979_0-1738252819983.png

 

Thanks for your help.

 

1 ACCEPTED SOLUTION

    RoundDollars = Table.TransformColumns (
        TransformDollars,
        List.Transform (
            Dollars_Columns_Selected,
//         each {_, Number.Round(_, 3), type number})) >> this is wrong, must be 
            each {_, (x) => Number.Round(x, 3), type number}
        )
    )    

View solution in original post

8 REPLIES 8
Mic1979
Post Partisan
Post Partisan

Hello,

I don't see any function in your file.

I know this is possible with standard approach from Power Query, but I am trying to built a function...

 

Thanks.

Mic1979
Post Partisan
Post Partisan

Hello,

did you mean changes like this:

 

RoundDollars = Table.TransformColumns (
TransformDollars,
List.Accumulate(
Dollars_Columns_Selected,
TransformDollars,
(a,b)=> Table.TransformColumns(a,{{b, each Number.RoundUp(_,3), Int64.Type}})))

 

If so, I got the following error:

Mic1979_0-1738320012866.png

 

Hi @Mic1979 ,

 

Yes,  Based on the data you provided, I have used it as sample data on my end and successfully implemented it. Therefore, please refer to the attached pbix file.

 

I hope this should resolve your issue, if you need any further assistance, feel free to reach out.

 

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

Thankyou,
Have a great day ahead.

Omid_Motamedise
Super User
Super User

use the following formula, source is the name of table in the previous step

 

= List.Accumulate(List.Select(Table.ColumnNames(Source), each Text.Contains(_,"$")),Source,
(a,b)=>Table.TransformColumns(a,{{b, each Number.RoundUp(_,3), Int64.Type}}))

If my answer helped solve your issue, please consider marking it as the accepted solution. It helps others in the community find answers faster—and keeps the community growing stronger!
You can also check out my YouTube channel for tutorials, tips, and real-world solutions in Power Query with the following link
https://youtube.com/@omidbi?si=96Bo-ZsSwOx0Z36h
Mic1979
Post Partisan
Post Partisan

    RoundDollars = Table.TransformColumns (
        TransformDollars,
        List.Transform (
            Dollars_Columns_Selected,
//         each {_, Number.Round(_, 3), type number})) >> this is wrong, must be 
            each {_, (x) => Number.Round(x, 3), type number}
        )
    )    

Thanks Alien

lbendlin
Super User
Super User

sounds like a mixup between column names and column values.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
Do not include sensitive information. Do not include anything that is unrelated to the issue or question.
Please show the expected outcome based on the sample data you provided.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 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.

Top Kudoed Authors