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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
kcsteele
Helper I
Helper I

Line chart x-axis with whole numbers - can't seem to retain leading 0s

I have an additional column added to my "years" table which is only the last 2 digits of the year because that's the format of the chart I need to make. However, when set as "whole numbers" power bi automatically removes any leading 0's. I need to keep the leading 0s. So I changed the data type to "text". Problem solved, however, now I am unable to set the start/end of the range of the x-axis and I get a scrollbar along it. Is it possible to have the "whole numbers" data type and retain the leading 0s? Or vice versa, is it possible to have the "text" data type and show the full range without the scrollbar?

 

Here is an image if it's helps explain it better:

 

powerbi-01.png

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @kcsteele ,

Here are the steps you can follow:

1. Enter into Mode

vyangliumsft_4-1632471939013.png

2. Click on the column [YearTrunc] of the yearsTest table and select Formatting.

Format – Custom

Custom -- 00

vyangliumsft_1-1632471799728.png

3. The column [YearTrunc] becomes the format with 0 in front, and it is also an whole number.

vyangliumsft_2-1632471799731.png

4. Result.

vyangliumsft_3-1632471799735.png

 

Best Regards,

Liu Yang

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

10 REPLIES 10
Anonymous
Not applicable

Hi  @kcsteele ,

Here are the steps you can follow:

1. Enter into Mode

vyangliumsft_4-1632471939013.png

2. Click on the column [YearTrunc] of the yearsTest table and select Formatting.

Format – Custom

Custom -- 00

vyangliumsft_1-1632471799728.png

3. The column [YearTrunc] becomes the format with 0 in front, and it is also an whole number.

vyangliumsft_2-1632471799731.png

4. Result.

vyangliumsft_3-1632471799735.png

 

Best Regards,

Liu Yang

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

Hi v-yangliu-msft,

 

Brilliant! It worked.

PaulDBrown
Community Champion
Community Champion

You can use the filters in the filter pane to establish the range for the visual





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






still get the scrollbars

To avoid the scrollbars the axis must be set as continuous. 
You can share a file by sharing the link to the file in OneDrive, Google Drive, Dropbox...





Did I answer your question? Mark my post as a solution!
In doing so, you are also helping me. Thank you!

Proud to be a Super User!
Paul on Linkedin.






I gave a google drive link. Thanks again!

vanessafvg
Super User
Super User

you could create two fields, put the text on the axis as you have but then use the other fields to filter your text field? problem is, you want number functions with text so thats not gonna work.  you would also just use a date table and then have a text field in that date table which you can also filter using a date - although i might misunderstand what are you trying to set a range for





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




Thanks, I need to retain the actual data points on the line however and if I filter out any years I believe those "dots" will disappear. The problem is resolved if I simply make the chart larger, because the scroll bar goes away and all the years show.

 

I'm trying to keep the chart at the same size and keep all the data points, and also retain the full x-axis range without the scrollbar. All the years do not need to show on the x-axis, I just need all the data points without the scroll bar. Ideally it would show only every 2 or 5 years on the x-axis (00, 05, 10, 15, 20) or (00, 02, 04, 06, 08 etc) but keeping the data points on the line. (I can achieve this when it's set to whole numbers, but then power bi removes the leading 0s...)

 

I guess I can just make a mock-image of what the x-axis should look like and just place it over the graph?

if you are able to share some data or dummy data then i could try mock something up





If I took the time to answer your question and I came up with a solution, please mark my post as a solution and /or give kudos freely for the effort 🙂 Thank you!

Proud to be a Super User!




I would like to attach the .pbix but I don't see an option to do that. Here is a google drive link

 

https://drive.google.com/file/d/1It2Ltp6aIyqDznLxe2GtKYZzM6sYCpG-/view?usp=sharing

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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