Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Stacked Column X Axis

I have a sheet that tracks different accounts and their expiration dates. I have a calculated column within PowerBi, that calculates if the account is to expired within 1 month, 2 month, 3 month, 4 month, 5 month, 6 month, 7 month +. (For the purposes of this example, I have created this calculated column with my excel spreadsheet). The Sheet also includes additional information, such as Language, Region and Type. I have created a hirearchy as follows:

Region Hierarchy: Type, Region

 

I have a simple column stacked chart:

Axis:

- Expiration

- Region Hierarchy > Region

Legend: 

Region Hierarchy > Type

Value

- Count of Names

 

The data source only has information for accounts: that have already expired, or expiring within 1 month, 2 month, 5 months, 6 months 7 + months. 

 

Currently the X Axis in the chart only shows: 1 month, 2 month, 5 months, 6 months 7 + months. 

What I am hoping to see is the X Axis with: Expired, 1 Month, 2 Month, 3 Month, 4 Month, 5 Month, 6 Month, 7 + Month. Understanding that there would be 0 values on 3 month and 4 month.

 

Thanks for the help,

 

Sample Data:

 

Sample Graph:

  • Hey,

     

    just create a new table, that contains all the possible values.

    Create a relationship between the new table (on the one side) and your existing table (on the many side), this article explains how to create relationships: https://docs.microsoft.com/en-us/power-bi/desktop-create-and-manage-relationships

     

    Use the column from the new table as axis, and make sure you enable this option "Show items with no data":

     

    Hopefully this provides what you are looking for.

     

    Regards,

    Tom

4 Replies

  • Hey,

     

    just create a new table, that contains all the possible values.

    Create a relationship between the new table (on the one side) and your existing table (on the many side), this article explains how to create relationships: https://docs.microsoft.com/en-us/power-bi/desktop-create-and-manage-relationships

     

    Use the column from the new table as axis, and make sure you enable this option "Show items with no data":

     

    Hopefully this provides what you are looking for.

     

    Regards,

    Tom

  • Cmcmahan's avatar
    Cmcmahan
    Resident Rockstar

    If you click the dropdown arrow on your axis field (Expiration in your case) you should see an option to Display Items with no data.  Selecting this will show you the expected blanks for month 3 & month 4.

     

    After that, it's all about ordering your graph by X-Axis category.  It should be easy to get 1-7 months in order, with expired after 7, since that's alphabetical order.  If you want expired first, you'll need to set up an ordering column that indicates what order the categories should be sorted in and use that.

    • TomMartens's avatar
      TomMartens
      Super User

      Hey Cmcmahan ,

       

      I assume that the current data does not contain the "missing" values, fo this reason I suggested to create a "dimension" table, we will see ...

       

      Regards,

      Tom

      • Cmcmahan's avatar
        Cmcmahan
        Resident Rockstar

        You're right TomMartens. Good catch.

         

        Since these categories are treated as text by the Power BI engine, it is unaware that it should make a "3 months" and a "4 months" category on its own.   The benefit of creating the new table that lists each of the possible category options is that you can set up an index column and sort by that to get the desired order of categories on the X-Axis.