Forum Discussion
How to create custom column in calendar table for 9 day rotating shifts
Basically you wll add a comma to your final step, then add this code (I picked up with your final else clause. Delete everything below that and add this:
...
else [Year]),
varRowCount = Table.RowCount(#"Added Custom2"),
varListNeeded =
List.FirstN(
List.Repeat(tblCycle, Number.RoundAwayFromZero(varRowCount / 9)),
varRowCount
),
CombinedWithCycleList = Table.ToColumns(#"Added Custom2") & {varListNeeded},
BackToTable =
Table.FromColumns(
CombinedWithCycleList,
Table.ColumnNames(#"Added Custom2") & {"Cycle"}
)
in
BackToTable
This assumes the Cycle data (1st, 2nd, etc) is in a list called "tblCycle" - see how I did it in Excel.
If you have a file you can share, I can help you connect it. Or you might look at the blog post at the end of these directions.
How to use M code provided in a blank query:
1) In Power Query, select New Source, then Blank Query
2) On the Home ribbon, select "Advanced Editor" button
3) Remove everything you see, then paste the M code I've given you in that box.
4) Press Done
5) See this article if you need help using this M code in your model.
Hi edhans,
I added the M code to the end of the current code, but I'm getting a Syntax Error (Token Comma Expected). I'm unable to attache the file b/c I think you have to be a Super User to do so? Here are a few more screenshots of what I'm experiencing.
Thank you
Elyse
- edhans3 years ago
Community Champion
You have to add a comma after your else [Year]) line. Look again at my code.
That is the break telling it there is a difference between your #"Added Custom2" step and the varRowCount step.- Elyse8083 years agoRegular Visitor
Hi edhans,
Sorry for the delay I got pulled into another project. I am now getting an error that says, "Expression.Error: the Import Added Custom2 matches no exports. Did you miss a module reference?"
Could you please assist
Thank you,
Elyse