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

Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM. Register now.

Reply
Pbiuserr
Post Prodigy
Post Prodigy

Random binary (1 and 0) column for each ID

Hello,

My database looks like that

IDStatus
ID1A
ID1A
ID1A
ID2A
ID2A
ID3A

 

I would like to just create a random 0 1 column for each ID (so if ID got 1, it needs to have 1 in every row, same with 0).

Expected result

IDStatusNewBinaryColumn
ID1A1
ID1A1
ID1A1
ID2A0
ID2A0
ID3A1

 

I have like 500k of distinct ID's. How to get such column?

Thank you in advance

1 ACCEPTED SOLUTION
johnt75
Super User
Super User

You could do this in Power Query. Make a second query which references your original query, remove all columns other than the ID and then remove duplicate values. Add a new column which is 

Number.Round( Number.RandomBetween(0,1) )

and then join this table back onto the original table

View solution in original post

1 REPLY 1
johnt75
Super User
Super User

You could do this in Power Query. Make a second query which references your original query, remove all columns other than the ID and then remove duplicate values. Add a new column which is 

Number.Round( Number.RandomBetween(0,1) )

and then join this table back onto the original table

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!

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.