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

How to make a graph understand that the week number is next year (to make the date sort right)?

Hi, 

 

I have this data: 

Table_date and sales.png

 

And I have made this graph - which shows completed sales and expected future sales.

Date_graph.png

 

This works great for when I use the "Date" field, but I want it on week level, and when I do that it looks strange (see picture below), because Power BI doesn't understand that week 1 is next year, and hence is after week 52. 

Week.png

 

Is there a way to make it understand that week 1 is next year? And hence that the graph looks more similar to the one with "Date"?

 

Thanks in advance, highly appreciate it 🙂

2 ACCEPTED SOLUTIONS

Hi @blinabj ,

 

Understood.

I think it's best not to use date hierarchy in concatenate labels, and to use custom dates for the best time.

So you can add a column names Year.

Year = YEAR('Table'[Date]) 

Then you can set the visual like this :

vyinliwmsft_0-1667897317420.png

vyinliwmsft_1-1667897330713.png

When you set the column in the visualizations, you may achieve this:

vyinliwmsft_3-1667897397120.png

Please click this button:

vyinliwmsft_4-1667897490670.png

Then you will achieve this:

vyinliwmsft_5-1667897516252.png

 

Hope this helps you. For more information, you can refer my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

View solution in original post

Hi @blinabj ,

 

Understood.

I can reproduce your question:

vyinliwmsft_0-1667899743844.png

 

Looks like this, right?

So this is because the year column, you can reset this column and refresh the visual.

vyinliwmsft_1-1667899881508.png

Of course this solution is dynamic, it will change with your data changed.

 

Hope you success!

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

11 REPLIES 11
v-yinliw-msft
Community Support
Community Support

Hi @blinabj ,

 

Understood. 

Could you please tell me that how do you create your X-Axis?

Did you create the X-Axis by this method below?

vyinliwmsft_0-1667890917075.png

Or you use the concatenate labels?

vyinliwmsft_3-1667891200882.png

 

And could you please show a screenshot to me the visualizations about your visual? Here.

vyinliwmsft_1-1667890997077.png

By the way, it looks like that your two tables have no relationships because the Average Sales is a straight line.

Like this:

vyinliwmsft_2-1667891103146.png

 

Hope this helps you.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hi @v-yinliw-msft,

 

Thanks! Here are the answer to the questions: 

 

I use the concatenate labels for the x-axis.

 

Here:

Skjermbilde 2022-11-08 093241.png

 

The tables have a relation, but no connection, so they basically act as two independent tables yes. But I didn't think that matter, because I want the Average Sales measure to be a straight line. I calculate the Average Sales measure by summing up all sales the last year and dividing it by 52 weeks, I don't want the average sales per week to change for each week.

 

Thanks for the help!

Hi @blinabj ,

 

Understood.

I think it's best not to use date hierarchy in concatenate labels, and to use custom dates for the best time.

So you can add a column names Year.

Year = YEAR('Table'[Date]) 

Then you can set the visual like this :

vyinliwmsft_0-1667897317420.png

vyinliwmsft_1-1667897330713.png

When you set the column in the visualizations, you may achieve this:

vyinliwmsft_3-1667897397120.png

Please click this button:

vyinliwmsft_4-1667897490670.png

Then you will achieve this:

vyinliwmsft_5-1667897516252.png

 

Hope this helps you. For more information, you can refer my PBIX file.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

Hi again @v-yinliw-msft,

 

Thank you so much for taking the time! I don't know what I am doing wrong, but I tried using Year as you wrote, but it doesn't work... Note! The solution need to be dynamic.

 

It just looks like this:

Skjermbilde 2022-11-08 102125.png

 

Thanks!

 

Hi @blinabj ,

 

Understood.

I can reproduce your question:

vyinliwmsft_0-1667899743844.png

 

Looks like this, right?

So this is because the year column, you can reset this column and refresh the visual.

vyinliwmsft_1-1667899881508.png

Of course this solution is dynamic, it will change with your data changed.

 

Hope you success!

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Ah, I understand! Thank you so much, it works now 🙂

v-yinliw-msft
Community Support
Community Support

Hi @blinabj ,

 

You can try this method:

Add a column:

Weeks = YEAR('Table'[Date]) & 'Table'[Week]

 

Then you can use this column to be the x-axis.

vyinliwmsft_0-1667531236751.png

 

 

Hope this helps you.

Here is my pbix file.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@blinabj , Add Year and week both in visual and expand , Or use Year week column

 

Year week = Year([Date]) *100 + Weeknum([Date])

 

Both Year and week column 

Concatenate Label off : https://youtu.be/QgI0vIGIOOk

Hi @amitchandak ,

 

Thank you for the help! The Year and week column (concatenate label) works as desired. But, I also need an average line, and then it stops working. Because I then get a lot of extra weeks I don't want in the visual, se picture.

 

How can I solve this? It is very important that the solution is dynamic, when the dates change everyday.

 

Graph visual.png

Hi @blinabj ,

 

After my testing, there are two known cases in which this result occurs.

The first one: Your average sales is a sample data like:

Average = 1500

In this case, it will occur this:

vyinliwmsft_0-1667888877734.png

Or ,the second situation, it's because your data in the visual doesn't come from the same table, like this:

vyinliwmsft_1-1667888995711.png

So i suggest you to calculate the Average Sales that use the data in the same table.

Because I don't know how you calculate the Average Sales, so I make an example:

AverageSales = DIVIDE(SUM('Table'[Completed sales]) + SUM('Table'[Estimated future sales]), COUNT('Table'[Date]))

 

For more information to understand, you can refer my PBIX file below.

 

Hope this helps you.

 

Best Regards,

Community Support Team _Yinliw

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-yinliw-msft ,

 

Thanks for helping! The average is calculated based on another table, and this is done due to the fact that I want it to be a yearly average sales last year divided down to week level (and the table making the graph only goes a couple of days back and forward). Is there anyway to do it with data from another table? Highly appreciate the help 🙂

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.

Top Solution Authors