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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
MatthiasVC
New Member

NULL to 0 conversion fails when Category is added to line+column chart

I'm building a dashboard with Stafplanning. People have complained that when filtering certain departments the line value does not show correct values (namely in in-between periods where it should be 0, it just links periods before and after).
For the departments where there is an actual 0 in the source table, this is not an issue, however I try to create a zero-value for some categories and it works until I add the category.

Problem:
I have the following data: (basically column "Category" is department, Colum "Type" is whether the hours are originally Planned planned (Base), Actual or Current Planned hours.

CategoryTypeMonthFTE
ABase01-12-20240
ABase01-01-202510
BBase01-01-202512
ABase01-02-20250
ABase01-03-20257
BBase01-03-20256
ABase01-04-20250
AActual01-01-20259
BActual01-01-202512
APlanned01-02-20250
APlanned01-03-20258
BPlanned01-03-202510

I then have following measures to extract the proper information:

Actual FTE = CALCULATE(Sum('Stafplanning_FTE'[FTE]),FILTER('Stafplanning_FTE','Stafplanning_FTE'[Type]="Actual"))
Base FTE = CALCULATE(Sum('Stafplanning_FTE'[FTE]),FILTER('Stafplanning_FTE','Stafplanning_FTE'[Type]="Base"))
Planned FTE = CALCULATE(Sum('Stafplanning_FTE'[FTE]),FILTER('Stafplanning_FTE','Stafplanning_FTE'[Type]="Planned"))
Actual/Planned = [Actual FTE]+[Planned FTE]

Now the problem is that I want Actual/Planned to be shown on columns and Base FTE on a line.
The base FTE should show a dip in feb/25 because nothing was planned there. It does it correctly as long as "A" is in the selection, however when only "B" is in the selection, the dip disappears and it connects jan/25 and march/25 in a straight line.
Effects of filters on the Graph with/without Zero correctionEffects of filters on the Graph with/without Zero correction
I tried to correct this using a measure that tries to ignore the "category filter" temporarily, checks if the date is between the minimum and maximum date within range that has data (because I don't want Dec/24 and Apr/25 in my chart) and then convert NULLs to zeroes within that range. (see below DAX). The measure seems to work in a table and in the chart WITHOUT column categories, however as soon as the column category is turned on again the dip disappears again (see center graph in the bottom).

Base FTE OR 0 =
VAR CurrentMonth =
    CALCULATE ( MAX ( Date_Table[Month] ), ALL ( Stafplanning_FTE[Category] ) ) -- Get MIN and MAX week from all selected activities
VAR MinSelectedMonth =
    CALCULATE (
        CALCULATE (
            MIN ( Stafplanning_FTE[Month] ),
            ALL ( Stafplanning_FTE[Category] ),
            FILTER ( Stafplanning_FTE, Stafplanning_FTE[FTE] > 0 )
        ),
        ALL ( Date_Table[Month] )
    )
VAR MaxSelectedMonth =
    CALCULATE (
        CALCULATE (
            MAX ( Stafplanning_FTE[Month] ),
            ALL ( Stafplanning_FTE[Category] ),
            FILTER ( Stafplanning_FTE, Stafplanning_FTE[FTE] > 0 )
        ),
        ALL ( Date_Table[Month] )
    )
VAR Base = [Base FTE]
VAR ReturnValue =
    IF ( NOT ISBLANK ( Base ), Base, 0 )
RETURN
    IF (
        CurrentMonth >= MinSelectedMonth
            && CurrentMonth <= MaxSelectedMonth,
        ReturnValue,
        BLANK ()
    )

How Can I resolve this without having to resort to adding lots of zeros in my original table?
Kind regards, 
Matthias

1 ACCEPTED SOLUTION

MFelix's answer allowed me to stumble into the solution.
I was focused on changing the DAX for 'Base FTE or Zero' however that DAX was not incorrect and already turned the NULL to 0 where appropriate.
The solution was to basically do the same for Actual/Planned:

Actual/Planned = 
VAR CurrentMonth = CALCULATE(MAX(Date_Table[Month]),ALL(Stafplanning_FTE[Category]))
-- Get MIN and MAX week from all selected activities
VAR MinSelectedMonth = 
    CALCULATE(
            CALCULATE(
                MIN(Stafplanning_FTE[Month]),ALL(Stafplanning_FTE[Category]),
                FILTER(Stafplanning_FTE,Stafplanning_FTE[FTE]>0)
            ),
            ALL(Date_Table[Month])
        )
VAR MaxSelectedMonth = 
    CALCULATE(
            CALCULATE(
                MAX(Stafplanning_FTE[Month]),ALL(Stafplanning_FTE[Category]),
                FILTER(Stafplanning_FTE,Stafplanning_FTE[FTE]>0)
            ),
            ALL(Date_Table[Month])
        )
VAR APValue = [Actual FTE]+[Planned FTE]
VAR ReturnValue = 
    IF(
        NOT ISBLANK(APValue),
        APValue,
        0
    )
RETURN
IF(CurrentMonth >= MinSelectedMonth && CurrentMonth <= MaxSelectedMonth,ReturnValue,BLANK())

Apparently the way the Column+line chart works is like this:
=> If there is no column legend: calculate for all X-axis values ALL column+Line chart values. Drop the data where everything is NULL
=> If there is a column legend:  calculate all for all X-axis values/column legend combo ALL column values. Drop the data where everything is NULL. Then calculate all Line values.

Or at least that's how I interpret this result.
SO in order to have the 0 value when a column legend is selected, I have to make sure the column also has a 0 value and not only NULLS.

View solution in original post

5 REPLIES 5
lbendlin
Super User
Super User

To report on things that are not there you need to use disconnected tables and/or crossjoins.

 

In your scenario this means that the Date table needs to be disconnected.

that would indeed help however I was hoping for a solution without changing my model, only my DAX (and I found one)

MFelix
Super User
Super User

Hi @MatthiasVC ,

 

Try to add a +0 on the the original measure:

Base FTE = CALCULATE(Sum('Stafplanning_FTE'[FTE]),FILTER('Stafplanning_FTE','Stafplanning_FTE'[Type]="Base")) + 0

This should convert the value from null to 0


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



MFelix's answer allowed me to stumble into the solution.
I was focused on changing the DAX for 'Base FTE or Zero' however that DAX was not incorrect and already turned the NULL to 0 where appropriate.
The solution was to basically do the same for Actual/Planned:

Actual/Planned = 
VAR CurrentMonth = CALCULATE(MAX(Date_Table[Month]),ALL(Stafplanning_FTE[Category]))
-- Get MIN and MAX week from all selected activities
VAR MinSelectedMonth = 
    CALCULATE(
            CALCULATE(
                MIN(Stafplanning_FTE[Month]),ALL(Stafplanning_FTE[Category]),
                FILTER(Stafplanning_FTE,Stafplanning_FTE[FTE]>0)
            ),
            ALL(Date_Table[Month])
        )
VAR MaxSelectedMonth = 
    CALCULATE(
            CALCULATE(
                MAX(Stafplanning_FTE[Month]),ALL(Stafplanning_FTE[Category]),
                FILTER(Stafplanning_FTE,Stafplanning_FTE[FTE]>0)
            ),
            ALL(Date_Table[Month])
        )
VAR APValue = [Actual FTE]+[Planned FTE]
VAR ReturnValue = 
    IF(
        NOT ISBLANK(APValue),
        APValue,
        0
    )
RETURN
IF(CurrentMonth >= MinSelectedMonth && CurrentMonth <= MaxSelectedMonth,ReturnValue,BLANK())

Apparently the way the Column+line chart works is like this:
=> If there is no column legend: calculate for all X-axis values ALL column+Line chart values. Drop the data where everything is NULL
=> If there is a column legend:  calculate all for all X-axis values/column legend combo ALL column values. Drop the data where everything is NULL. Then calculate all Line values.

Or at least that's how I interpret this result.
SO in order to have the 0 value when a column legend is selected, I have to make sure the column also has a 0 value and not only NULLS.

Hi @MatthiasVC ,

 

Glad you were able to figure it out. Don't forget to mark the correct answer so it can help others.


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors