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
rg72
Frequent Visitor

Last 8 weeks - In order

Hi all.

 

I'm building a graph to show a rolling 8 weeks of tickets resolved by a support team. The data is being pulled directly from service now via odbc.

 

Using help on here provided to others, I've got the graph to show the last 8 weeks of data, however the axis is sorted in numerical order, rather than date order. I've been wracking my brain on how to re-order the axis, but no joy.

 

Screen Shot 2018-01-15 at 11.36.41.png

 

The code used to generate is ...

 

"Week", each Date.ToText(Date.StartOfWeek ([sys_created_on], Day.Monday), "dd/MM") & "-" & Date.ToText(Date.EndOfWeek([sys_created_on],Day.Monday),"dd/MM"))

 

Obviously this is using date to text, hence the ordering issue, but I'm not sure how to proceed.

 

I think I can cut out the 2nd part of the formula (ie the "- xx/xx' part) and just have an effective week commencing date of dd/MM, but it's then how I convert that to be able to get the correct sort order that I'm suck at.

 

Any help would be greatly appreciated.

 

TIA

 

Rob

 

1 ACCEPTED SOLUTION
gooranga1
Power Participant
Power Participant

Hi @rg72,

 

@Rfranca is correct, this is far easier with a date dimension however using your customised field of "dd/MM" will be problematic as you cannot gurantee that that combination is unique for that week over several years which is typically what you get in a date dimension. For example  26/12-01/01 occurs in 2011 and 2016.

 

If you are using just a small amount of data not spanning more than a few years you won't get this problem however. Using the last 90 days of my date dimesnion I created a "dummy" dimension table using your format so that it's order correctly.

 

Create StartDateOfWeek and Custom.2 columns in your original table.

 

Dates.PNG

Copy that table as a new table and group the new table as so.

Dates1.PNG

Then join the new table and original table together on start date of week

Dates2.PNG

Then sort your custom column in the new table.

Dates5.PNG

Then you can use the custom2 field as your axis

Dates6.PNG

And it will ordered correctly.

 

I am not a big fan of date formats like that and I would much prefer to see a date as the start of week in "yyyy-MM-dd" format.

View solution in original post

14 REPLIES 14

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.