This time we’re going bigger than ever. Fabric, Power BI, SQL, AI and more. We're covering it all. You won't want to miss it.
Learn moreDid you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now
Hello everyone,
i want to add a index column with following conditions:
I have 2 different columns counting upwards, first column 1 counts to from 1 to 3, while column 2 remains 0.
When 3 is reached in column 1 in next step, column 2 starts counting from 1 to 3 and index should increase by 1 while column 1 remain 3.
When 3 is reached in column 2 in next step, column 1 restarts counting from 1 to 3 and index should increase by 1 while column 2 remain 3.
Process continues alternating. Steps are not always from 1 to 3, it could vary for example from 1 - 151 or from 1 - 150 aswell.
Please find below the corresponding table:
| Column 1 | Column 2 | Index |
| 1 | 0 | 1 |
| 2 | 0 | 1 |
| 3 | 0 | 1 |
| 3 | 1 | 2 |
| 3 | 2 | 2 |
| 3 | 3 | 2 |
| 1 | 3 | 3 |
| 2 | 3 | 3 |
| 3 | 3 | 3 |
Anyone got a suggestion for this problem?
Looking forward to any support.
@SimonSchoutz , To achieve this you can use Power Query
Add an Index Column:
In the Power Query Editor, add an index column by clicking on Add Column > Index Column > From 1.
Create Custom Columns:
Create custom columns for Column 1, Column 2, and Index using the following M code.
Proud to be a Super User! |
|
EDIT:
Oh sorry, i think there was a missunderstanding on my side.
I don´t want to create column 1 and 2, they are already existing machine data.
The maximum value in column 1 and 2 can vary depending how long the machine was running.
EDIT2:
Okay, i understood, where i have to insert M-Code, but problem still exist.
I don´t want to create a new column 1 and 2, they already exist.
Here is an example of actual machine data:
| 2,1 | 154,9 |
| 7,8 | 154,9 |
| 12,2 | 154,9 |
| 16,6 | 154,9 |
| 21 | 154,9 |
| 25,4 | 154,9 |
| 29,9 | 154,9 |
| 34,3 | 154,9 |
| 38,7 | 154,9 |
| 43,1 | 154,9 |
| 47,5 | 154,9 |
| 51,9 | 154,9 |
| 56,3 | 154,9 |
| 60,7 | 154,9 |
| 65,1 | 154,9 |
| 69,5 | 154,9 |
| 73,9 | 154,9 |
| 78,3 | 154,9 |
| 82,7 | 154,9 |
| 87,1 | 154,9 |
| 91,5 | 154,9 |
| 95,9 | 154,9 |
| 100,3 | 154,9 |
| 104,7 | 154,9 |
| 109,1 | 154,9 |
| 113,4 | 154,9 |
| 117,9 | 154,9 |
| 122,3 | 154,9 |
| 126,7 | 154,9 |
| 131,1 | 154,9 |
| 135,5 | 154,9 |
| 139,9 | 154,9 |
| 144,3 | 154,9 |
| 148,7 | 154,9 |
| 153 | 154,9 |
| 154,9 | 2,3 |
| 154,9 | 6,9 |
| 154,9 | 11,4 |
| 154,9 | 15,9 |
| 154,9 | 20,3 |
| 154,9 | 24,7 |
| 154,9 | 29 |
| 154,9 | 33,5 |
| 154,9 | 37,8 |
| 154,9 | 42,3 |
| 154,9 | 46,6 |
| 154,9 | 51,2 |
| 154,9 | 55,6 |
| 154,9 | 60 |
| 154,9 | 64,4 |
| 154,9 | 68,7 |
| 154,9 | 73,2 |
| 154,9 | 77,5 |
| 154,9 | 82 |
| 154,9 | 86,3 |
| 154,9 | 90,8 |
| 154,9 | 95,2 |
| 154,9 | 99,6 |
| 154,9 | 104,1 |
| 154,9 | 108,4 |
| 154,9 | 112,9 |
| 154,9 | 117,2 |
| 154,9 | 121,7 |
| 154,9 | 126 |
| 154,9 | 130,5 |
| 154,9 | 134,9 |
| 154,9 | 139,2 |
| 154,9 | 143,7 |
| 154,9 | 148 |
| 154,9 | 152,5 |
| 0,3 | 154,6 |
| 6,6 | 154,6 |
| 10,9 | 154,6 |
| 15,4 | 154,6 |
| 19,9 | 154,6 |
| 24,2 | 154,6 |
| 28,7 | 154,6 |
| 33 | 154,6 |
| 37,5 | 154,6 |
| 41,8 | 154,6 |
| 46,3 | 154,6 |
| 50,7 | 154,6 |
| 55 | 154,6 |
| 59,4 | 154,6 |
| 63,8 | 154,6 |
| 68,3 | 154,6 |
| 72,6 | 154,6 |
| 77,1 | 154,6 |
| 81,4 | 154,6 |
| 85,9 | 154,6 |
| 90,3 | 154,6 |
| 94,6 | 154,6 |
| 99 | 154,6 |
| 103,4 | 154,6 |
| 107,9 | 154,6 |
| 112,2 | 154,6 |
| 116,7 | 154,6 |
| 121 | 154,6 |
| 125,4 | 154,6 |
| 129,8 | 154,6 |
| 134,1 | 154,6 |
| 138,6 | 154,6 |
| 142,9 | 154,6 |
| 147,4 | 154,6 |
| 151,7 | 154,6 |
| 154,8 | 0 |
| 154,8 | 5,7 |
| 154,8 | 10,1 |
| 154,8 | 14,6 |
| 154,8 | 18,9 |
| 154,8 | 23,4 |
| 154,8 | 27,8 |
| 154,8 | 32,3 |
| 154,8 | 36,6 |
| 154,8 | 41 |
| 154,8 | 45,5 |
| 154,8 | 49,8 |
| 154,8 | 54,3 |
| 154,8 | 58,6 |
| 154,8 | 63,1 |
| 154,8 | 67,5 |
| 154,8 | 71,9 |
| 154,8 | 76,3 |
| 154,8 | 80,7 |
| 154,8 | 85,1 |
| 154,8 | 89,5 |
| 154,8 | 93,9 |
| 154,8 | 98,3 |
| 154,8 | 102,7 |
| 154,8 | 107,1 |
| 154,8 | 111,5 |
| 154,8 | 115,9 |
| 154,8 | 120,3 |
| 154,8 | 124,7 |
| 154,8 | 129,1 |
| 154,8 | 133,5 |
| 154,8 | 137,9 |
| 154,8 | 142,3 |
| 154,8 | 146,7 |
| 154,8 | 151,1 |
| 154,8 | 154,5 |
| 5,4 | 154,5 |
| 9,8 | 154,5 |
Kind regards,
Simon
Check out the April 2026 Power BI update to learn about new features.
Sign up to receive a private message when registration opens and key events begin.
If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.
| User | Count |
|---|---|
| 34 | |
| 31 | |
| 25 | |
| 20 | |
| 16 |
| User | Count |
|---|---|
| 61 | |
| 49 | |
| 28 | |
| 23 | |
| 23 |