Hi @Nick1,
Welcome to the Forum!
Beside the reference provided by @lsquintana17, you could also explore something like this.
Add an Odd-/Even week field to your date table with something like this:
Table.AddColumn( PrevStepNameHere, "Odd-/Even Week", each
if Number.IsOdd([ISO Weeknumber])
then "Odd"
else "Even"
)
Create a supporting query by referencing your Date table and extracting one these fields
Load this table into memory with Table.Buffer - Iāve called this query DateSmall
Merge that with an unpivoted version of your Contract table. You can copy and paste this example into a new blank query. After youāve added the DateSmall table described above.
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WMjQAAhMLJR0lQ10zXSMDI0M409QAxDQAkRZYsAEU45MzUIrVAdqBMB0kaGyoawq3iVLjYwE=", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [id = _t, startdate = _t, enddate = _t, employee_id = _t, hours_monday_odd = _t, hours_tuesday_odd = _t, hours_wednesday_odd = _t, hours_thursday_odd = _t, hours_friday_odd = _t, hours_saturday_odd = _t, hours_sunday_odd = _t, hours_monday_even = _t, hours_tuesday_even = _t, hours_wednesday_even = _t, hours_thursday_even = _t, hours_friday_even = _t, hours_saturday_even = _t, hours_sunday_even = _t, internal_price_per_hour = _t]),
ChType = Table.TransformColumnTypes(Source,{{"id", Int64.Type}, {"startdate", type date}, {"enddate", type date}, {"employee_id", Int64.Type}, {"hours_monday_odd", Int64.Type}, {"hours_tuesday_odd", Int64.Type}, {"hours_wednesday_odd", Int64.Type}, {"hours_thursday_odd", Int64.Type}, {"hours_friday_odd", Int64.Type}, {"hours_saturday_odd", Int64.Type}, {"hours_sunday_odd", Int64.Type}, {"hours_monday_even", Int64.Type}, {"hours_tuesday_even", Int64.Type}, {"hours_wednesday_even", Int64.Type}, {"hours_thursday_even", Int64.Type}, {"hours_friday_even", Int64.Type}, {"hours_saturday_even", Int64.Type}, {"hours_sunday_even", Int64.Type}, {"internal_price_per_hour", Int64.Type}}),
UnpivotOthers = Table.UnpivotOtherColumns(ChType, {"id", "startdate", "enddate", "employee_id", "internal_price_per_hour"}, "Attribute", "Value"),
ReplaceValue = Table.ReplaceValue(UnpivotOthers, each [Attribute], each Text.Proper( Text.AfterDelimiter( [Attribute], "_")),Replacer.ReplaceValue,{"Attribute"}),
SplitByDelimiter = Table.SplitColumn(ReplaceValue, "Attribute", Splitter.SplitTextByEachDelimiter({"_"}, QuoteStyle.Csv, false), {"Weekday name", "odd-/Even Week"}),
MergeDateSmall = Table.NestedJoin(SplitByDelimiter, {"Weekday name", "odd-/Even Week"}, DateSmall, {"DayOfWeekName", "Odd-/Even Week"}, "DateSmall", JoinKind.LeftOuter),
FilterDateSmall = Table.ReplaceValue(MergeDateSmall, each [DateSmall], each Table.SelectRows([DateSmall], (x)=> x[Date] >= [startdate] and x[Date] <= [enddate]),Replacer.ReplaceValue,{"DateSmall"}),
ExpandDate = Table.ExpandTableColumn(FilterDateSmall, "DateSmall", {"Date"}, {"Date"}),
RemoveColumns = Table.RemoveColumns(ExpandDate,{"Weekday name", "odd-/Even Week", "startdate", "enddate", "internal_price_per_hour"})
in
RemoveColumns
With this result.
Hereās your sample file (please note to include a data file in future along with your PBIX.)
Availablity v1.pbix (350.2 KB)
I hope this is helpful