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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! 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
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.