Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 28 - August 9 | Final Round of the Power BI Dataviz World Championships. This is your chance. Learn more
Imagine you are working for a company that have, let's say it has 10 branches. Your task is to create lists for A/B testing, so you need to prepare a new colum classifies customers in category A or B. (Group by Bank)
So you can have a table like this.
In an Ideal world you will have even number of customer, so for eks 80 can be divided in 40 A and 40 B, but in reallity odd figures will appear so for eks 81, then it will be 40 A and 41 B.
| Bank | Kunde | AB Test |
| A | 1 | A |
| A | 2 | B |
| A | 3 | A |
| A | 4 | B |
| A | 5 | A |
| A | 6 | B |
| A | 7 | A |
| A | 8 | B |
| A | 9 | A |
| A | 10 | B |
| A | 11 | A |
| A | 12 | B |
| A | 13 | A |
| A | 14 | B |
| A | 15 | A |
| A | 16 | B |
| B | 1 | A |
| B | 2 | B |
| B | 3 | A |
| B | 4 | B |
| B | 5 | A |
| B | 6 | B |
| B | 7 | A |
| B | 8 | B |
| B | 9 | A |
| B | 10 | B |
| B | 11 | A |
| B | 12 | B |
| B | 13 | A |
Solved! Go to Solution.
Hi @patoduck
Sorry but I'm not sure if I understand your requirement, are you looking to create a column that alternates between a and b?
If so please consider the below solution.
=if Number.IsOdd( [Kunde] ) then "A" else "B"
Hi @patoduck
Sorry but I'm not sure if I understand your requirement, are you looking to create a column that alternates between a and b?
If so please consider the below solution.
=if Number.IsOdd( [Kunde] ) then "A" else "B"
At the end i did it on SQL rank () over (partition by Banknr order by CustomerNr ) as ranking and then use a CASE with (ranking % 2) <> 0 to find odd and even numbers.
In Power BI you can do it by creating an index Group By and then as suggested by Marius use
Number.IsOdd =if Number.IsOdd( [Kunde] ) then "A" else "B"
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
If you love stickers, then you will definitely want to check out our community sticker challenge, Barcelona edition!
Check out the July 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 30 | |
| 28 | |
| 25 | |
| 24 | |
| 16 |
| User | Count |
|---|---|
| 48 | |
| 32 | |
| 17 | |
| 16 | |
| 16 |