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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
schoden
Post Partisan
Post Partisan

Apply Certain Date Range using ISBLANK

Hi Community, 

 

I have a measure to calculate total sales:

 

 

 

M= SUM(Sales[sales])

 

 

 

Now  I have put Date Range to show next 6 Months including current Month Feb 2021.

 

 

N= CALCULATE(M, DATESINPERIOD( Date, NOW(), 6 , MONTH)))

 

 

 

This is result :Missing May.JPG

 

May and July is blank hence doesnt appear , to show them on the graph;

 

 

 

Y= IF(ISBLANK(N), 0 , N) 

 

 

This pulls up entire date data and shows zero for entire date where as I needed for next 6 months only.

 

whole.JPG

 

 

1 ACCEPTED SOLUTION

@schoden , Try like

 

0 between range 
Measure = var _1= CALCULATE(SUM(Sales[sales]), DATESINPERIOD( Date, NOW(), 6 , MONTH)) +0 
var _min = calculate(minx('Calendar', 'Calendar'[Date]) ,DATESINPERIOD( 'Calendar'[, NOW(), 6 , MONTH))
var _max = calculate(maxx('Calendar', 'Calendar'[Date]) ,DATESINPERIOD( 'Calendar'[, NOW(), 6 , MONTH))
return
CALCULATE(if(max('Calendar'[Date]) <_min || max('Calendar'[Date]) >_max , BLANK(), _1))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

10 REPLIES 10
Ashish_Mathur
Super User
Super User

Hi,

See if my solution here helps - Flex a Pivot Table to show data for x months ended a certain user defined month.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur  Thanks for the share .  I am facing problem to show zero value for all blank months in the specified date range. 

amitchandak
Super User
Super User

@schoden , Create a measure like below example

 

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

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

hi @amitchandak  the measure still doesnt show zero for the blank months.

@schoden , here min-max, need to be from six-month range.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Yes @amitchandak  I have put flag check for next 6 months.  still doesnt show zero

revenue.JPGcheck.JPG

@schoden , I tried on my file. Please check the file attached after the signature. Check Page 13

 

Zero in range.png

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

@amitchandak  Thanks for the share.

 

However I need for next 6 months including current month from 01/02/2021 that is current month start date. 

 

Today.JPG

 

This filter starts from 8/02/2021 as its todays date. 

I have used datesinperiod with specified start and end date 

@schoden , Try like

 

0 between range 
Measure = var _1= CALCULATE(SUM(Sales[sales]), DATESINPERIOD( Date, NOW(), 6 , MONTH)) +0 
var _min = calculate(minx('Calendar', 'Calendar'[Date]) ,DATESINPERIOD( 'Calendar'[, NOW(), 6 , MONTH))
var _max = calculate(maxx('Calendar', 'Calendar'[Date]) ,DATESINPERIOD( 'Calendar'[, NOW(), 6 , MONTH))
return
CALCULATE(if(max('Calendar'[Date]) <_min || max('Calendar'[Date]) >_max , BLANK(), _1))
Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you so much 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors