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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Randyr
Frequent Visitor

Grouping by Week Starting Date

Hello, I am a new Power BI user.  I am looking at Salesforce Live Chat Transcript cases and I am trying to count how many cases were created by week.

 

I have been able to do this by creating a new Column   Week = WEEKNUM('Live Chat Transcript'[StartTime])

 

And this new Measure - WeekGroup = CALCULATE(Count('Live Chat Transcript'[CaseId]), ALLEXCEPT('Live Chat Transcript','Live Chat Transcript'[Week]))

 

This shows me the information by Week 1, Week2, etc. However I want to be able to show  Week Starting ...Jan 1, Jan 8, Jan 15, etc.    

 

I appreciate any assistance you can provide on how I can do this.

 

Thanks

1 ACCEPTED SOLUTION

Thank you Angelia, I beleive I have it now.

 

The problem was that I had to create a new column on my date table for "Weeks", then join the "Live Agent Created Date" field to that new column on the Date tab. Once I did that, it is now showing up correctly.

 

Thanks again for the help!

 

Randy

View solution in original post

12 REPLIES 12
Randyr
Frequent Visitor

Thank you very much Brett, that new measure is now grouping the dates the way I want.  I am still doing something wrong though, if I add a visual table to look at the data, I group by the new measure I created.   "WeekStarting".  Then I created another measure to count the number of cases like so.

 

WeekGroup = CALCULATE(COUNT('Live Chat Transcript'[CaseId]),ALLEXCEPT(DateKey,DateKey[WeekStarting].[Date]))

 

Here is what I see....I think I have the count messed up somehow, it is not summarizing the number of cases by the new measure you gave me, it is totaling them.

 

new.png

 

 

Here is the way it looked before.

 

old.png

 

Thanks again! I appreciate any help you can provide here.

 

 

Can you check the direction of the date relationship?  I have mine set to "Both".

Thank you, yes it is set to 'both' now but no change i'm afraid.

Can you explain what you are trying to do with the ALLEXCEPT filter?

Sorry, again I'm new. I was using that filter to group the rows by week. Something I picked up here : http://community.powerbi.com/t5/Desktop/Group-By-Using-Weeks/m-p/30754/highlight/true#M10514  

 

 

Not a problem, I'm by no means an expert.

 

Here is what I believe the ALLEXCEPT clause will do.  In the case where you have a date slicer, if you filter by a specific day the count will include the count for the entire week.  If your count does not inlcude the ALLEXCEPT clause your count will only include the records for that specific day.  

 

For the example below:

 

WeekGroup = CALCULATE(COUNT('Data'[ID]))

 

WeekGroup2 = CALCULATE(COUNT('Data'[ID]),ALLEXCEPT(Data,Data[Week]))

 

Capture.PNG

 

There is a single record for January 3 and 4 records between January 2 - 8.

 

Do you know how you will be filtering and how you want the data to respond?

Ah, I see. Thank you.

 

No, I will not require a data slicer for this. I just want to show how many cases were created by week. 

Hi @Randyr,

I create sample data and test, you need to remove ".[Date]" from your formula.

WeekGroup = CALCULATE(COUNT('Live Chat Transcript'[CaseId]),ALLEXCEPT(DateKey,DateKey[WeekStarting]))


Or you also use the following measure, it still return right result.

WeekGrounp11=COUNT('Live Chat Transcript'[CaseId])


Best Regards,
Angelia

Thank you Angelia, I must be doing something wrong as it is still not working for me.  The grouping looks correct.

 

weekstarting1.png

 

Then when I drag the count formula in, it changes to this.

 

weekstarting2.png

 

I appreciate any further suggestions you have.

 

Regards,

 

Randy

Hi @Randyr,

Do you mind share your .pbix file forfurther analysis?

Angelia

Thank you Angelia, I beleive I have it now.

 

The problem was that I had to create a new column on my date table for "Weeks", then join the "Live Agent Created Date" field to that new column on the Date tab. Once I did that, it is now showing up correctly.

 

Thanks again for the help!

 

Randy

bjnodello
Helper II
Helper II

Welcome Randy,

 

I generally use a CALENDARAUTO() table (DateData) in my reports.  In this table I create a "Week Starting" column (among others) with the following formula:

 

Week Starting = IF(WEEKDAY('DateData'[Date],2)=1,'DateData'[Date],DATEADD('DateData'[Date],-WEEKDAY('DateData'[Date],2)+1,DAY))

 

This gives me the Monday of the current week for each date.  I then join this table to my main data tables with the dates.

 

Let me know if this helps or you have other questions.

 

Brett

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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