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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
dp32
Helper I
Helper I

Expression.Error: We cannot apply field access to the type Number.

I am trying to randomize data in-place:

 

#"Randomize" = Table.TransformColumns(#"Changed Type1", {{"Value", each Number.RandomBetween(0.95,1.05)*[Value]}})

 

However, I get the following error message:

Expression.Error: We cannot apply field access to the type Number.
Details:
Value=4567,35
Key=Value

The column [Value] is of type number, so I don't understand the problem here.
Any idea? Thanks in advance.

1 ACCEPTED SOLUTION
Anonymous
Not applicable

try this

#"Randomize" = Table.TransformColumns(#"Changed Type1", {{"Value", each Number.RandomBetween(0.95,1.05)*_}})

 

 

PS

if the answer works for you and you want to know how and why it works, just ask

View solution in original post

6 REPLIES 6
edhans
Super User
Super User

It isn't in the current context. Try the following syntax:

 

        Table.TransformColumns(
            RowData, 
            {
                {
                    "Value", 
                    each _ * Number.RandomBetween(0.95,1.05),
                    type number
                    }
                }
            )

 

However, note that this isn't doing what you think. Put this in a new custom column:

Number.RandomBetween(0.5,.95)

Every value is the same random number. You can either try the method in this article, or do what I would do. Either use a Measure in DAX, or a calculated column in DAX where each row or iteration is really random.

MS should document this in their  Number.Random* documentation, but they don't. I just avoid both Number.Random and Number.RandomBetween in Power Query. DAX is better here, usually.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting

Thank you all. Working fine with the underscore.

@edhans , the random function is also working fine if I add an index column.

Good to hear @dp32 , glad you have a solution that works.



Did I answer your question? Mark my post as a solution!
Did my answers help arrive at a solution? Give it a kudos by clicking the Thumbs Up!

DAX is for Analysis. Power Query is for Data Modeling


Proud to be a Super User!

MCSA: BI Reporting
Anonymous
Not applicable

 

I can't be sure what your intention is with the formula in question, but if you need examples of how to get some random set points, you can follow the discussion here (see in particular the last post 😁😞

 

How-to-turn-randbetween-results-into-a-static-column-in-Power 

Anonymous
Not applicable

try this

#"Randomize" = Table.TransformColumns(#"Changed Type1", {{"Value", each Number.RandomBetween(0.95,1.05)*_}})

 

 

PS

if the answer works for you and you want to know how and why it works, just ask

Greg_Deckler
Community Champion
Community Champion

@ImkeF @edhans  ?



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

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 community update carousel

Fabric Community Update - June 2025

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