Skip to main content
cancel
Showing results forย 
Search instead forย 
Did you mean:ย 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Gemni
New Contributor

Adjusting Week Grouping Logic in Power BI Matrix Table

hi! im new here, can someone pls help me with this? thank you!

 

i have a matrix table

rows: nr tagging[new region], customer[customer name]

columns: productivity[weekperiod]

values: productivity[actual]

 

currently this is the output of my columns in the table:

Wk - 1 Mon-Wed | Wk - 1 Thu-Sat | Wk -2 Mon-Wed | Wk -2 Thu-Sat

 

First column is always "Wk1 Mon-Wed", even if the first group of the first week of the month falls under the group of "Wk-1 Thu-Sat". How can I correct this? if week 1 starts on a tuesday or wednesday or thursday, then the first column should be Wk-1 Thu-Sat, if week 1 starts on a sat or sun or mon, then the first column should be Wk-1 Mon-Wed. The group should be complete (mon-wed) and (thu-sat). letโ€™s say in the month of Sep 2024, week 5 is only until Monday, then there shouldnโ€™t be Wk-5 Mon-Wed since Tues and Wed falls on the next month.

In June 2024, day 1 started on a Saturday, so the first column should be "Wk-1 Mon-Wed".

 

WeekPeriod = VAR WeekNum = โ€œWk - โ€œ & Productivity[Week_5] VAR DayGroup = Productivity[Weekday Group] RETURN IF(ISBLANK(DayGroup), BLANK(), WeekNum & โ€œ โ€œ & DayGroup) Week_5 = VAR Num = INT ((Productivity[FORM ANSWER DATE] โ€ข [Day]-1)/7)+1 RETURN IF ( Num > 5, 5, Num )

 

Weekday Group = SWITCH ( TRUE () , Productivity [Weekday] >= 1 && Productivity[Weekday] <= 3, "Mon-Wed" , Productivity [Weekday] >= 4 && Productivity[Weekday], <= 6, "Thu-Sat", BLANK())

1 ACCEPTED SOLUTION
lbendlin
Esteemed Contributor III

All of this is immutable.  There is no need to calculate this with Power Query or DAX.  Use an externally sourced calendar table that for each day indicated which week sub group it belongs to.

 

lbendlin_2-1729557083163.png

lbendlin_3-1729557136713.png

 

 

View solution in original post

3 REPLIES 3
lbendlin
Esteemed Contributor III

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Gemni
New Contributor

Thank you for the response!

To clarify my issue, here's some sample data that reflects the problem I'm encountering with my matrix table:

 

Rows: NAME

Columns: WeekPeriod

Values: Actual

 

Filtered by the month of October 

NAMEWeek 1 Mon-WedWeek 1 Thu-SatWeek 2 Mon-WedWeek 2 Thu-SatWeek 3 Mon-WedWeek 3 Thu-Sat
Brix            1            1             1           1            1    1
Zoey            1              1           1     1

 

- October 2024 starts on a Tuesday, so the first column should be "Week 1 Thu-Sat" because the first three days of the week (Mon-Wed) don't form a complete group.

- Only display complete groups of Mon-Wed and Thu-Sat. For example, if a week only has a part of Mon-Wed or Thu-Sat that spills into the next month, it shouldn't be displayed in the header.

 

here's more sample filtered by the month of April:

NAMEWeek 1 Mon-WedWeek 1 Thu-SatWeek 2 Mon-WedWeek 2 Thu-SatWeek 3 Mon-WedWeek 3 Thu-SatWeek 4 Mon-WedWeek 4 Thu-SatWeek 5 Mon-Wed
Brix            1            1             1           1            1     1    1    1 
Zoey            1              1           1      1    1    1    1

 

- this April table should only have 8 columns since the last group of Mon-Wed isn't complete April 29-30 as Monday and Tuesday, because Wed falls on the next month.

 

Please let me know if this helps or if you need further clarification. Thank you

lbendlin
Esteemed Contributor III

All of this is immutable.  There is no need to calculate this with Power Query or DAX.  Use an externally sourced calendar table that for each day indicated which week sub group it belongs to.

 

lbendlin_2-1729557083163.png

lbendlin_3-1729557136713.png

 

 

Helpful resources

Announcements
Users online (3,586)