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
MirkoCantatore
New Member

Date hierarchy custom range

Dear all,

I have a table with dates from Novembre 2017 and October 2018.

On April 2018 I have no data

Power BI Desktop has Time Intelligence option enabled and date hierarchy is fine.

Result is like that

image.png

 

As you can see no bar for April 2018.

If I choose "Show Items with no data", I get this

image.png

 

As you can see April is shown with no data, but I have other months I do not need (Jan-Oct 2017 and Nov-Dec 2018).

Is there a way to filter/customize the chart to show me only Nov 2017 - Oct 2018 and April 2018 (wih no data) like below?

Thanks

Kind regards

image.png

 

 

 

1 ACCEPTED SOLUTION
AkhilAshok
Solution Sage
Solution Sage

If you can create a Date table (if you don't already have one - you can just google "How to create Date Table in Power BI"), this can be easily achieved with some DAX:

 

Continuous Measure =
VAR MainMeasure =
    SUM ( 'Table'[Amount] )
VAR CurrentDate =
    MAX ( 'Calendar'[Date] )
VAR MaxDate =
    CALCULATE ( MAX ( 'Table'[Date] ), ALL ( 'Calendar' ) )
VAR MinDate =
    CALCULATE ( MIN ( 'Table'[Date] ), ALL ( 'Calendar' ) )
RETURN
    IF (
        ISBLANK ( MainMeasure )
            && CurrentDate <= MaxDate
            && CurrentDate >= MinDate,
        0,
        MainMeasure
    )

Here Table[Date] is the date column in your Fact/Data table, and Calendar[Date] is you Date dimension table, and you create a relationship between these 2.

View solution in original post

2 REPLIES 2
AkhilAshok
Solution Sage
Solution Sage

If you can create a Date table (if you don't already have one - you can just google "How to create Date Table in Power BI"), this can be easily achieved with some DAX:

 

Continuous Measure =
VAR MainMeasure =
    SUM ( 'Table'[Amount] )
VAR CurrentDate =
    MAX ( 'Calendar'[Date] )
VAR MaxDate =
    CALCULATE ( MAX ( 'Table'[Date] ), ALL ( 'Calendar' ) )
VAR MinDate =
    CALCULATE ( MIN ( 'Table'[Date] ), ALL ( 'Calendar' ) )
RETURN
    IF (
        ISBLANK ( MainMeasure )
            && CurrentDate <= MaxDate
            && CurrentDate >= MinDate,
        0,
        MainMeasure
    )

Here Table[Date] is the date column in your Fact/Data table, and Calendar[Date] is you Date dimension table, and you create a relationship between these 2.

Thank you very much.

It works.

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.

Top Solution Authors