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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ITManuel
Responsive Resident
Responsive Resident

Show items with no data -- Limiting date range issue

Hi,

 

I have a column chart which simply show values which have been sumed up by a measure.

CC1.PNG

 

 

 

 

 

 

 

Activating the "Show items with no data" option the chart turns into the following, visualizing the entire date range ( + blank row ) of the date table on the x-Axis, which I guess is a normal behaviour. 

 

CC2.PNG

 

 

 

 

 

 

 

 

I would like to keep the  "Show items with no data" option in order to visualize items with no data in between the first appearance and the last appearance of data but would like to exclude on the x-Axis anything before the first and after the last date with date, so exclude anything before September 2023 and after November 2025 in the above case. 

 

I tried to limit the calculation with the following code, but unfortunately it does not work:

 

 

Inv = 
VAR _MinDate =
    CALCULATE (
        MIN ( Tasks[TaskStartDate] ),
        Tasks[TaskIsSummary] = FALSE,
        Tasks[_Invoicingamount] > 0
    )
VAR _MaxDate =
    CALCULATE (
        MAX ( Tasks[TaskStartDate] ),
        Tasks[TaskIsSummary] = FALSE,
        Tasks[_Invoicingamount] > 0
    )
VAR _Result =
    CALCULATE (
        SUM ( Tasks[_Invoicingamount] ),
        Tasks[TaskIsSummary] = FALSE,
        FILTER ( ALL ( 'Date' ), 'Date'[Date] >= _MinDate && 'Date'[Date] <= _MaxDate )
    )
RETURN
    _Result

 

 

 

The _MinDate and _MaxDate are retreiving the Min- and MaxDate correctly, but the resctriction of the date x-Axis is not working at all. 

 

This is my datamodel:

DM.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Thanks in advance and best regards

4 REPLIES 4
nirali_arora
Resolver II
Resolver II

Instead of filter, you should try if statement like the following example

0 between range 
Measure = var _1= SUM(Opportunity[Opportunity count]) +0 
var _min = minx(ALLSELECTED('Calendar'), 'Calendar'[Date]) 
var _max = maxx(ALLSELECTED('Calendar'), 'Calendar'[Date]) 
return
if(max('Calendar'[Date]) <_min || max('Calendar'[Date]) >_max , BLANK(), _1)

Hi @nirali_arora ,

 

I tried your proposed solution but unfortunately it is not working. I would assume that both solutions work, but none of it does in my case. 

CC3.PNG

 

 

 

 

 

 

 

 

 

 

InvTest = 
VAR _MinDate =
    CALCULATE (
        MIN ( Tasks[TaskStartDate] ),
        Tasks[TaskIsSummary] = FALSE,
        Tasks[_Invoicingamount] > 0
    )
VAR _MaxDate =
    CALCULATE (
        MAX ( Tasks[TaskStartDate] ),
        Tasks[TaskIsSummary] = FALSE,
        Tasks[_Invoicingamount] > 0
    )
VAR _MinDate1 =
    MINX ( ALLSELECTED ( 'Date' ), 'Date'[Date] )
VAR _MaxDate1 =
    MAXX ( ALLSELECTED ( 'Date' ), 'Date'[Date] )
VAR _Result =
    CALCULATE ( SUM ( Tasks[_Invoicingamount] ), Tasks[TaskIsSummary] = FALSE ) + 0
VAR _ResultLimited =
    IF (
        MAX ( 'Date'[Date] ) > _MinDate1
            || MAX ( 'Date'[Date] ) < _MaxDate1,
        _Result,
        BLANK ()
    )
RETURN
    _ResultLimited

 

 

 

ITManuel
Responsive Resident
Responsive Resident

Hi,

 

I still have the same issue described above which I was unable to resolve. When I activate the "Show items with no data" option on the Date X-Axis, the entire range of the Date table is shown, even if in the measure the calculation should be limited to a date range between Min and Max of available data. 

 

This is my data: 

DataTaskTable.png

 

 

 

 

This is my model:

DataModel.png

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

This is the measure I'm using:

 

InvPWA = --Invoiced according to 100% Milestone in PWA
VAR _MinDate =
    CALCULATE (
        MIN ( Tasks[TaskStartDate] ),
        TasksHeader[TaskIsMilestone] = 1,
        Tasks[_Invoicingamount] > 0,
        Tasks[TaskPercentCompleted] = 100
    )
VAR _MaxDate =
    CALCULATE (
        MAX ( Tasks[TaskStartDate] ),
        TasksHeader[TaskIsMilestone] = 1,
        Tasks[_Invoicingamount] > 0,
        Tasks[TaskPercentCompleted] = 100
    )
VAR _Result =
    CALCULATE (
        SUM ( Tasks[_Invoicingamount] ),
        TasksHeader[TaskIsMilestone] = 1,
        Tasks[_Invoicingamount] > 0,
        Tasks[TaskPercentCompleted] = 100,
        'Date'[Date] >= _MinDate
            && 'Date'[Date] <= _MaxDate
    )
VAR _ResultLimited =
    IF (
        AND ( MAX ( 'Date'[Date] ) >= _MinDate, MAX ( 'Date'[Date] ) <= _MaxDate ),
        _Result
    )
RETURN
    _Result

 

 

_MinData return correctly the 09.01.2023 as the first date with available data and _MaxDate return correctly the 30.06.2023 as the last date with available data.

However the result in the bar chart is the following, always showing the entire date range of the date table on the X-Axis, limiting the calculation to the desired range in between _MinDate and _MaxDate is not working.

Neither the _Result nor _ResultLimited variable works.

 

Chart.png

 

Thanks in advance

ITManuel
Responsive Resident
Responsive Resident

Hi Community,

 

any help here would be much appreciated. 😀 I cannot figure out why this is not working. 🙈

 

Thanks

 

Best regards

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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