The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
Hello, I'm trying to find an M formula that with increase the increment by 1 after every 3 rows. For example:
Row # Index
1 1
2 1
3 1
4 2
5 2
6 2
7 3
8 3
9 3
Thanks very much for any suggestions!
Solved! Go to Solution.
Hi @mstone3
You can achieve this by the GUI without any custom formula. Follow below steps!
First add an Index column starting from 1.
Then divide Index column by 3. From Transform tab > (Number Column) Standard > Divide.
Finally round up Index column. Transform > (Number Column) Rounding > Round Up.
Anyway, if you want a single M formula to get the same result, you can combine above three steps into one step. Paste below code into the formula bar and modify previous step name.
= Table.TransformColumns(Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type), {{"Index", each Number.RoundUp(_ / 3), type number}})
Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
Hi @mstone3
You can achieve this by the GUI without any custom formula. Follow below steps!
First add an Index column starting from 1.
Then divide Index column by 3. From Transform tab > (Number Column) Standard > Divide.
Finally round up Index column. Transform > (Number Column) Rounding > Round Up.
Anyway, if you want a single M formula to get the same result, you can combine above three steps into one step. Paste below code into the formula bar and modify previous step name.
= Table.TransformColumns(Table.AddIndexColumn(#"Changed Type", "Index", 1, 1, Int64.Type), {{"Index", each Number.RoundUp(_ / 3), type number}})
Regards,
Community Support Team _ Jing
If this post helps, please Accept it as the solution to help other members find it.
Thanks very much - this is a great solution!
This would work. If your prior step is named LastStep, add a new step. In the formula bar, type:
= Table.AddColumn(LastStep, "NewIndex", each if Number.Mod([Index], 3) = 0 then [Index]/3 else null)
Then you can use Fill Up function in the GUI for the missing values.
--Nate
Thank you very much!