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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Pawel_J
Frequent Visitor

Line and stacked column chart – displaying all months when using legend

 

Hello,

 

In my sample data model I have 2 tables. First table contains information about sales, the second table is a date table created using DAX. 

 

I’m currently facing an issue with my line and stacked column chart. I’m trying to display the monthly sales amount in columns and the running total in a line. For the first scenario the visual is working correctly and shows all the months of the year on the x-axis, even if there were no sales in a specific month:

Pawel_J_0-1715608777840.png

The situation changes when I am adding a column legend, the months with no sales disappear:

Pawel_J_1-1715608847066.png

I’m looking for a solution that allows me to include the column legend without losing the display of months with zero sales.

 

Below I am sending the sample sales table:

 

 

CompanyTransaction dateFruit nameFruits sold
A11/10/2022Banana4
A11/10/2022Apple2
A12/5/2022Apple1
A1/9/2023Apple3
B1/9/2023Banana3
A1/10/2023Banana2
A1/20/2023Apple4
B2/2/2023Apple12
A2/28/2023Apple2
B3/17/2023Banana3
B4/13/2023Apple4
A4/26/2023Apple6
A5/1/2023Apple3
A6/7/2023Apple8
A6/7/2023Apple3
A7/13/2023Apple2
B8/21/2023Apple2
A10/30/2023Apple5
A11/10/2023Banana4
A12/5/2023Apple1

 

Here is the date table created using DAX:

Date = 
VAR MinYear = YEAR ( MIN ( 'Fruits sales'[Transaction date] ) )
VAR MaxYear = YEAR ( MAX ('Fruits sales'[Transaction date] ) )
RETURN
ADDCOLUMNS (
    FILTER (
        CALENDARAUTO( ),
        AND ( YEAR ( [Date] ) >= MinYear, 
              YEAR ( [Date] ) <= MaxYear )
    ),
    "Year", YEAR ( [Date] ),
    "Month Name", FORMAT ( [Date], "mmmm" ),
    "Month Number", MONTH ( [Date] ),
    "Quarter", FORMAT( [Date], "\QQ" )
)

 

Here is the relationship:

Pawel_J_2-1715608983161.png

 

Here is the running total formula:

Running Total = 
CALCULATE (
    SUM('Fruits sales'[Fruits sold]),
    DATESYTD( 'Date'[Date] )
)

 

Any help or guidance would be greatly appreciated.  

1 ACCEPTED SOLUTION
v-yangliu-msft
Community Support
Community Support

Thanks for the reply from @Ritaf1983 , please allow me to provide another insight: 
Hi  @Pawel_J ,

 

You can click X-axis - [Month Name] - Show items with no data.

vyangliumsft_0-1715663494100.png

vyangliumsft_1-1715663494103.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

3 REPLIES 3
Pawel_J
Frequent Visitor

Thank you very much for your responses. In my case I was using a measure only to calculate the running total and "Show items with no data" worked.

v-yangliu-msft
Community Support
Community Support

Thanks for the reply from @Ritaf1983 , please allow me to provide another insight: 
Hi  @Pawel_J ,

 

You can click X-axis - [Month Name] - Show items with no data.

vyangliumsft_0-1715663494100.png

vyangliumsft_1-1715663494103.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.

Ritaf1983
Super User
Super User

Hi @Pawel_J 
You can add 0 to the measure of bars.
For example (from my sample file) :

Total sales (K/$) = SUMX('orders',('orders'[Unit price]- [Discount])*'orders'[Quantity])+0
Ritaf1983_0-1715662555073.png

The pbix is attached

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

 

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.