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
adin
Helper I
Helper I

Best way to exclude calendar table months before data series starts

Hi Guys,

 

I'm using a calendar table in my data model and have a measure that shows zero when there are blanks. The reason I'm doing this is that I want to show a complete time series even if the customer doesn't make purchases in a particular month. The problem I'm having is because I'm removing the blanks in my measure, now my entire calendar table is showing up in the bar chart (see below). I need the bar chart to start from when the data series starts and yet display empty months after that. 

 

Screenshot 2020-11-12 110645.png

 

What are some of the ways you guys have dealt with this (ideally in an automatic way)? I can probably come up with something but wanted to see what the best practices are out there (i.e. the most effective way of doing it.).

 

Thanks Guys!

1 ACCEPTED SOLUTION
V-lianl-msft
Community Support
Community Support

Hi @adin ,

 

Create a measure like this and apply it to  visual level filter.

Measure = var min_ = CALCULATE(MIN(Sheet2[Date]),ALLEXCEPT(Sheet2,Sheet2[customer]))
var max_ = CALCULATE(MAX('calendar'[Date]))
return IF(max_>min_,1)

V-lianl-msft_0-1605580674833.png

V-lianl-msft_2-1605580763320.png

 

V-lianl-msft_1-1605580710065.png

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
V-lianl-msft
Community Support
Community Support

Hi @adin ,

 

Create a measure like this and apply it to  visual level filter.

Measure = var min_ = CALCULATE(MIN(Sheet2[Date]),ALLEXCEPT(Sheet2,Sheet2[customer]))
var max_ = CALCULATE(MAX('calendar'[Date]))
return IF(max_>min_,1)

V-lianl-msft_0-1605580674833.png

V-lianl-msft_2-1605580763320.png

 

V-lianl-msft_1-1605580710065.png

 

Best Regards,
Liang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mahoneypat
Employee
Employee

One way is to add an IF into your expression to compare the MIN(Date[Date]) to the overall MIN of your fact table

CALCULATE(MIN(Table[Date]), ALL(Table)).  That way, any months will be blank prior to the overall min, and not show in the visual.

Regards,

Pat





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Would I use CALCULATE(MIN(Table[Date]), ALLSELECTED(Table)) if I want my bar chart to dynamically respond to which customer the user selected from a drop-down filter?

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.