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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
sean_cochran
Resolver I
Resolver I

Plotting line with custom date hierarchy as x-axis

EDIT: sample file here.

I have a custom date hierarchy with three layers: year, year + month, and day. I have this date hierarchy set as the x-axis on a line chart.

 

One of the metrics on the chart is blank in some periods by design (comparatio). I want a line plotted between these points, but it isn't:

sean_cochran_1-1702668513348.png

I have read several other posts, and as I understand it, I must use a column with scalar values (date or number) and set the x-axis as continuous to see the line plotted. I have the relevant column set as a whole number:

sean_cochran_2-1702668567253.png

 

The lines are plotted correctly on the top level (year) of the hierarchy:

sean_cochran_4-1702668969880.png

 

But when I expand to the next level of the hirearchy (year+month), the option to set the x-axis as continuous disappears from the chart settings and the line is not plotted.

 

What am I missing to make this work? Is there anything I have misunderstood?

16 REPLIES 16
lbendlin
Super User
Super User

I have read several other posts, and as I understand it, I must use a column with scalar values (date or number) and set the x-axis as continuous to see the line plotted

Correct, whih means they all have to be date values.

 

sqlbi.com/articles/creating-a-simpler-and-chart-friendly-date-table-in-power-bi/

Are numbers not scalar?

Great question, and there is a big debate raging in the Vega community about the finer differences between "ordinal" and "nominal".  I think it all boils down to the continuity of the values.  Date values are by default assumed to have a natural order (the arrow of time) whereas all others could be random collections (ie categoricals)  (and yes, one could argue that at least integers have continuity - but someone decided otherwise).

Same result when I use dates (I used EOMONTH to create dates) instead of whole numbers. Any ideas?result.jpgdate.jpg

lbendlin_0-1703101130424.png

lbendlin_1-1703101209601.png

 

I see you removed the date hierarchy and that you highlighted the NaN values. What should I be taking away from this?

Yeah, sorry, didn't finish - got sidetracked. But you will want to investigate the NaN issue.

 

Will check later today 

lbendlin_0-1703120588720.png

But - notice that the X axis is still categorical, and once you add Turnover  it will revert back to the dots as the granularity doesn't match between the two measures.

 

Thanks for the follow up. I see you replaced my date hierarchy with a new one and zoomed into to a granularity that is based on text values (month abbreviation) rather than dates. This should result in a categorical x-axis, so your result is not surprising (unless I'm missing something?). Reverting back to my original hierarchy with scalar date values for the month-year level of granularity - I'm still confused why I can't get a continuous x-axis when the current level of my custom date hierarchy (month-year) is populated with scalar values. Is this because it is missing the metadata (that must be set with tabular editor) Mr. Russo mentioned at the bottom of his article? Regarding the NaN values - they were intentional since there isn't data for those periods and 0 isn't accurate. I was hoping for a solution that didn't require interpolation, but it sounds like that might be my best bet. What are your thoughts?

BLANK() is better than NaN.  Interpolation could solve this but do you really want to go there?

Thanks for the tip. I replaced the NaN values with blanks.

 

I want to avoid interpolation. Is it impossible to plot both lines if one measure is missing values for some periods?

I think that's what it boils down to. I'll do some more tests on my side.

Oddly, error bands are plotted correctly even though the line isn't:

sean_cochran_0-1703264804457.png

Which means that I can just plot the measure itself as an error band line:

sean_cochran_1-1703265195006.png

The downside of this approach is that the info bubbles get confusing, and you can't use the error bands anymore:

sean_cochran_2-1703265290533.png

 

 

 

I think you may want to raise a ticket with the product team. Sure sounds inconsistent.

I tried updating the metadata of my date hierarchy as Marco Russo described. Perhaps I made a mistake, but the x-axis did not change to continuous, so that seems like a dead end.

Thanks for the background - I didn't realize Power BI was opinionated on this topic. I thought I tried date values as well, but I must have missed something. I'll try again with dates and report back.

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!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.