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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
stenford23
Helper I
Helper I

[Bug] Number.Random is not random.

Hi PBPQ team,

 

I found a strange behavious which seems a bug to me.

 

Number.Random doesn't work in the correct way when used inside Table.Group or Table.TransformColumns.

 

- Expected behaviour:

Two table with column random_number containing different random value

 

- Real behaviour:

Two table with a column random_number containing the same value

 

bug.png

Until the last update i never see this behaviour and Number.Random was working correctly.

 

The following link contains the sample pbix to reproduce the bug

Dropbox to example Pbix 

1 ACCEPTED SOLUTION

Hi @stenford23 ,

 

How about this approach? Use List.Random(1) to get random number, then use the Table.ExpandListColumn function to expand the list.

 

= Table.ExpandListColumn(Table.TransformColumns(grouped_table, {"random_number", each List.Random(1), type number}),"random_number")

vkkfmsft_0-1658902662861.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

6 REPLIES 6
v-kkf-msft
Community Support
Community Support

Hi @stenford23 ,

 

I looked up the documentation and found that this problem seems to persist, when using Number.Random() to build transformations, at some point PQ will replace all numbers with same value.

There are several ways to solve this problem discussed in these documents.

Random Number being changed to the same number for all rows 

How to get a random sample of data with Power Query 

Random Number Generation in Power BI 

 

One way is to use the List.Random function, i.e. the following code:

 

 

= Table.Group(
        Source, "Column",
        {{"random_number", each List.Random(Table.RowCount(_)){0}, type number}}
    )
= Table.TransformColumns(grouped_table, {"random_number", each _, type number})

 

vkkfmsft_0-1658802272568.pngvkkfmsft_1-1658802288130.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Hi @v-kkf-msft 

Thanks for the reply

 

what about Table.TransformColumns?

 

you use only an each _ referring to previous step results.

 

Hi @stenford23 ,

 

How about this approach? Use List.Random(1) to get random number, then use the Table.ExpandListColumn function to expand the list.

 

= Table.ExpandListColumn(Table.TransformColumns(grouped_table, {"random_number", each List.Random(1), type number}),"random_number")

vkkfmsft_0-1658902662861.png

 

If the problem is still not resolved, please provide detailed error information or the expected result you expect. Let me know immediately, looking forward to your reply.
Best Regards,
Winniz
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-kkf-msft 

 

yes that's perfect.

 

Why Number.Random isn't working but List.Random is working as expected?

 

Shouldn't both command be idempotent and return same generated number?

Both are calculated once.

lbendlin
Super User
Super User

You can raise an issue at https://issues.powerbi.com . If you have a Pro license you can consider raising a Pro ticket at https://powerbi.microsoft.com/en-us/support/pro/

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 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