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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors