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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors