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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

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.
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 and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.