Show Blanks Between Date Range

SimonNU

Board Regular
Joined
Jul 11, 2013
Messages
140
I have the below dax pattern for showing blanks in a measure:
Code:
Count of Days Worked (no blanks):=IF(ISBLANK([Count of Days Worked]), 0, [Count of Days Worked])
For example, if i worked 1 day in Feb and 1 day in June then the output might be:
Jan: 0
Feb: 1
Mar: 0
Apr: 0
May: 0
Jun: 1
Jul: 0
Aug: 0
Sep: 0
Oct: 0
Nov: 0
Dec: 0

This works well for graphs and whatnot but the issue I'm now facing is I need to show blanks, like above, but only between the start date and end date of the measure in question. Therefore, the output should be:
Feb: 1
Mar: 0
Apr: 0
May: 0
Jun: 1

Any suggestions?

I imagine it would be something like :
Code:
Count of Days Worked (timeframe):=CALCULATE (    [Count of Days Worked (no blanks)],
    FILTER (
        ALL ( 'Date Table' ),
        'Date Table'[DateInt] >= CALCULATE ( MIN ( 'Date Table'[DateInt] ), 'Fact Table' ) && 'Date Table'[DateInt] <= MAX CALCULATE ( MAX ( 'Date Table'[DateInt] ), 'Fact Table' )
    )
)
 
Last edited:

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Well, I think I've got something working... It's a bit buggy though:
Code:
Count of Days(timeframe) :=IF (
    NOT (
        MIN ( 'Date Table'[DateInt] ) < MIN ( 'Employee Table'[First Date Worked] ) || 
        MAX ( 'Date Table'[DateInt] ) > MAX ( 'Employee Table'[Last Date Worked] )
    ),
    IF (
        ISBLANK ( [Count of Days] ),
        0,
        [Count of Days]
    )
)

I've referenced two calculated columns, here's a snippet from one of them:
Code:
First Date Worked=CALCULATE ( MIN ( 'Date Table'[DateInt] ) , RELATEDTABLE ( 'Fact Table' ) )
 
Upvote 0
Full pattern, it appears to work successfully:
Code:
Count of Days (timeframe):=IF (    NOT (
        MIN ( 'Date Table'[DateInt] ) < CALCULATE ( MIN ( 'Date Table'[DateInt] ) , RELATEDTABLE ( 'Fact Table' ) )
            || MAX ( 'Date Table'[DateInt] ) >CALCULATE ( MAX ( 'Date Table'[DateInt] ) , RELATEDTABLE ( 'Fact Table' ) )
    ),
    IF (
        ISBLANK ( [Count of Days] ),
        0,
        [Count of Days]
    )
)

Alternatives/improvements are welcome!
 
Upvote 0
The only thing I would add is that I switched to using 0 + [Count of Days]. I would assume its faster, but I haven't tested. certainly easier to write though :)
 
Upvote 0

Forum statistics

Threads
1,224,120
Messages
6,176,494
Members
452,732
Latest member
EWRUCK

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top