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
fedpar
Microsoft Employee
Microsoft Employee

Data type Date not sorting on a line chart

I'm trying to display some data on a line chart. Specifically, I want them to be split by week. I have a column called EventDate that contains DateTime values. To classify them by week, I created a custom column that performs the following:

Week =
if Date.IsInCurrentWeek([EventDate]) then null else Date.StartOfWeek([EventDate])

I have a page-level filter that removes anything that is null, so the conditional is there so that it doesn't display data for the current week until it's over.

 

When I try to display the data over a line graph, I get the following:

Capture.PNG

As can be seen from the screenshot, the date sorting is off, as it appears to be sorting it as if the labels were strings. If I click on the ... on the top right and click on Sort By Week, the problem persists. Why is this? How can I fix it? Looking at the query itself, the Week column is of type Date, not Text.

 

Thank you!

4 REPLIES 4
fedpar
Microsoft Employee
Microsoft Employee

The problem was that, upon applying a custom query, the column loses its type. In other words, even if you're referencing from a Date column, the new custom column will not be of type Date, and you have to manually set it to be one.

austinsense
Impactful Individual
Impactful Individual

Create a date table if you don't already have one

Austin is VP Operations at PowerPivotPro and a professional self-service enthusiast 🙂

What do you mean? The data is currently being imported from a SQL database.

You can read about data table structure here http://exceleratorbi.com.au/the-optimal-shape-for-power-pivot-data/

and date tables here http://exceleratorbi.com.au/power-pivot-calendar-tables/



* Matt is an 8 times Microsoft MVP (Power BI) and author of the Power BI Book Supercharge Power BI.
I will not give you bad advice, even if you unknowingly ask for it.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.