Damian
Damian

Reputation: 5174

Show only weeks with data using ALLSELECTED function in DAX

I'm trying to get a simple chart with columns for one value and a line for another value.

  1. I'm using a calculated calendar to show the week/year item with an order.
  2. A table with all the data and a calculated measure in DAX to show the acumulated for every week.

My problem is that the DAX measure is forcing all the weeks to show in the chart, even the ones without data (because they will get the acumulate from the ones before).

This is the measure:

P-Soll(sum) = CALCULATE(
    SUM(TEVON_parts_current_K[P-Soll]),
    ALLSELECTED(TEVON_parts_current_K),
    'Orden Semanas_Soll'[Index]<=MAX('Orden Semanas_Soll'[Index])
)

This is how it shows:

Chart

And these are the weeks with data:

Weeks_with_data

There are more, but you can get the idea. Is there any way to show only the weeks with real data?

Upvotes: 1

Views: 257

Answers (1)

Mik
Mik

Reputation: 2103

try If like

P-Soll(sum) = 

VAR CurrentWeekValue = ...
VAR Cumulative=
        CALCULATE(
            SUM(TEVON_parts_current_K[P-Soll])
            ,ALLSELECTED(TEVON_parts_current_K)
            ,'Orden Semanas_Soll'[Index]<=MAX('Orden Semanas_Soll'[Index])
        )
RETURN
    IF(CurrentWeekValue = 0,BLANK(),Cumulative)

Upvotes: 2

Related Questions