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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Gemni
Regular Visitor

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

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
Gemni
Regular Visitor

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

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

 

 

lbendlin
Super User
Super User

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...

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

Top Solution Authors