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
cookm
Frequent Visitor

Calculate Days Between

I am trying to count the day difference between the End Date on one Area compared to the Start Date of the next Area by Equipment based on a slicer selection for the Equipment being assigned to the Area. My current measure is calculating both pieces of equipment as one. How do I modify the measure to group by Equipment? My desired result is residing n the STAND_BY_DAYS column. 

 

STAND_BY_DAYS = datediff(minx(ALLSELECTED(Table),Table[START_DATE]),maxx(ALLSELECTED(Table),Table[END_DATE]),DAY)-SUMX(ALLSELECTED(Table),Table[DAYS])

 

cookm_0-1674587662593.png

 Thanks for the Help.

 

 

 

 

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @cookm 

You can refer to the following measure:

STAND_BY_DAYS = var _lastarea=MAXX(FILTER(ALLSELECTED('Table'),[EQUIPMENT]=MAX([EQUIPMENT])&&[AREA]<MAX([AREA])),[AREA])
var _lastenddate=MAXX(FILTER(ALLSELECTED('Table'),[AREA]=_lastarea&&[EQUIPMENT]=MAX([EQUIPMENT])),[END_DATE])
var _currentstartdate=MINX(FILTER(ALLSELECTED('Table'),[AREA]=MAX([AREA])&&[EQUIPMENT]=MAX([EQUIPMENT])),[START_DATE])
return IF(MAX('Table'[START_DATE])=_currentstartdate,DATEDIFF(_lastenddate,_currentstartdate,DAY))

vxinruzhumsft_0-1674702777089.png

 

Best Regards!

Yolo Zhu

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

4 REPLIES 4
v-xinruzhu-msft
Community Support
Community Support

Hi @cookm 

You can refer to the following measure:

STAND_BY_DAYS = var _lastarea=MAXX(FILTER(ALLSELECTED('Table'),[EQUIPMENT]=MAX([EQUIPMENT])&&[AREA]<MAX([AREA])),[AREA])
var _lastenddate=MAXX(FILTER(ALLSELECTED('Table'),[AREA]=_lastarea&&[EQUIPMENT]=MAX([EQUIPMENT])),[END_DATE])
var _currentstartdate=MINX(FILTER(ALLSELECTED('Table'),[AREA]=MAX([AREA])&&[EQUIPMENT]=MAX([EQUIPMENT])),[START_DATE])
return IF(MAX('Table'[START_DATE])=_currentstartdate,DATEDIFF(_lastenddate,_currentstartdate,DAY))

vxinruzhumsft_0-1674702777089.png

 

Best Regards!

Yolo Zhu

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

 

Thanks Yolo.

How about a measure to referance the STAND_BY_DAYS and divide by the job count per area and distibute to the jobs accordingly?

 

cookm_1-1674746830076.png

 

 

FreemanZ
Super User
Super User

hi @cookm 

1) Is the first 6 coulmns your sample data?

2) what context fo you have for the expected measure?

amitchandak
Super User
Super User

@cookm , A new column

 

Diff =

var _max = maxx(filter(Table, [equipment] = earlier([equipment]) && [END_DATE] < earlier([END_DATE])
&& [Area] <> earlier([Area]) ) , [END_DATE])
var _min = Minx(filter(Table, [equipment] = earlier([equipment]) && [Area] = earlier([Area]) ) , [JOB])
return

Switch( True() ,
_min = [JOB] && isblank(_max) , Blank() ,
_min = [JOB] , datediff(_min, [Start_date], day) ,
blank())

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