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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Ken_Jorp
Frequent Visitor

Display active dates based on date diff

Hi, I have two existing queries that counts historical days between redress in and redress out (active days) - and one that counts days if on active redress today.

My problem is that my existing queries sums the active days, and place the result on each redress out date. This creates a challenge for me when adding this measure to a date chart to display e.g average active days per month. As you see in the snip below, the item have been active in 35 days, but the result is only showing in July, whilst I need it to display sum of active days for June and July.

Also, for the last measure, that counts days on redress now, it shows 137 days in October, but should be showing all active days the last months.

Ken_Jorp_0-1614582448169.png

 

Here's my column and measures as is now:

DAYS ON REDRESS COL =
VAR myindex = CALCULATE(MAX (_ITH_All2[Index]),_ITH_All2[Location Status]="Redress Out")
VAR myserial = _ITH_All2[SERIAL_NO]
VAR previousindex =
CALCULATE (
MAX ( _ITH_All2[Index] ),_ITH_All2[Location Status]="Redress In",
FILTER ( _ITH_All2,_ITH_All2[SERIAL_NO] = myserial
&& _ITH_All2[Index] < myindex)
)
VAR previousdate =
CALCULATE (
MAX ( _ITH_All2[Date Applied] ),
FILTER (
_ITH_All2,
_ITH_All2[Index] = previousindex
&& _ITH_All2[SERIAL_NO] = myserial
)
)
RETURN
IF ( previousdate , _ITH_All2[Date Applied] - previousdate)
 
 Measures:
_Status =
VAR __id = MAX (_ITH_All2[SERIAL_NO] )
VAR __date = CALCULATE ( MAX(_ITH_All2[Date Applied] ), ALLSELECTED ('_ITH_All2' ), _ITH_All2[SERIAL_NO] = __id )
RETURN
CALCULATE ( Min (_ITH_All2[Location Status] ), VALUES ('_ITH_All2'[SERIAL_NO] ),'_ITH_All2'[SERIAL_NO] = __id,_ITH_All2[Date Applied]= __date )
last_date =
VAR __id = MAX (_ITH_All2[SERIAL_NO] )
VAR __date = CALCULATE ( MAX(_ITH_All2[Date Applied] ), ALLSELECTED ('_ITH_All2' ), _ITH_All2[SERIAL_NO] = __id )
RETURN
CALCULATE ( Min (_ITH_All2[Date Applied] ), VALUES (_ITH_All2[SERIAL_NO] ),_ITH_All2[SERIAL_NO] = __id,_ITH_All2[Date Applied] = __date )
Days On Redress now = sumx(values(_ITH_All2[SERIAL_NO]),if([_Status] ="Redress In", datediff([last_date], today(), day), blank()))
Days on redress historical= Sum(DAYS ON REDRESS COL)
 
Days on Redress All= Days on redress historical + Days On Redress now
 
So, a measure to display sum of active days for each period, and a measure to display average days per period would be highly appreciated. 
Thanks in advance!
0 REPLIES 0

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.