cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
rbangari001
Frequent Visitor

Calculate the no of days for a Epic which was spent in each state but NOT for "Closed" State

Hi,

 

I have created a Dax formula to calculate the "No. of days which was spent in each state". Now I dont want to see the ""No. of days which was spent in CLOSED state"

 

Below is the formula which I have used

 

Index=

CALCULATE(DISTINCTCOUNT('Epic - All History Daily'[Date]),
FILTER('Epic - All History Daily',
'Epic - All History Daily'[State]= EARLIER('Epic - All History Daily'[State]) &&
'Epic - All History Daily'[Date] <=EARLIER( 'Epic - All History Daily'[Date])))

 

 

Days Spent =
VAR vKEY = 'Epic - All History Daily'[Work Item Id]
VAR vINDEX = 'Epic - All History Daily'[Index]
VAR vState = 'Epic - All History Daily'[Phase]
RETURN
DATEDIFF(
CALCULATE( VALUES('Epic - All History Daily'[Date]),
FILTER( ALL('Epic - All History Daily'),
'Epic - All History Daily'[Work Item Id] = vKEY &&
'Epic - All History Daily'[Index] = (vINDEX - 1) &&
'Epic - All History Daily'[Phase] = vState
)
),'Epic - All History Daily'[Date],DAY)
 
Please let me know how should avoid calculating the No. of days for "Closed" State
 
Work Item IdDateState
11436/17/21Build
11436/18/21Build
11436/19/21Build
11436/20/21Build
11436/21/21Build
11436/22/21Build
11436/23/21UAT
11436/24/21UAT
11436/25/21UAT
11436/26/21UAT
11436/27/21UAT
11436/28/21UAT
11436/29/21UAT
11436/30/21Closed
11437/1/21Closed
11437/2/21Closed

 

 

@v-jingzhan @BA_Pete  @v-jingzhang  @v-stephen-msft  @v-yingjl 

 

 

 

 

 

1 ACCEPTED SOLUTION
v-jingzhang
Community Support
Community Support

Hi @rbangari001 

 

Is this what you want?

Index = IF('Epic - All History Daily'[State]="Closed",BLANK(),
CALCULATE(DISTINCTCOUNT('Epic - All History Daily'[Date]),
FILTER('Epic - All History Daily',
'Epic - All History Daily'[State]= EARLIER('Epic - All History Daily'[State]) &&
'Epic - All History Daily'[Date] <=EARLIER( 'Epic - All History Daily'[Date]))))

21120901.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

View solution in original post

2 REPLIES 2
v-jingzhang
Community Support
Community Support

Hi @rbangari001 

 

Is this what you want?

Index = IF('Epic - All History Daily'[State]="Closed",BLANK(),
CALCULATE(DISTINCTCOUNT('Epic - All History Daily'[Date]),
FILTER('Epic - All History Daily',
'Epic - All History Daily'[State]= EARLIER('Epic - All History Daily'[State]) &&
'Epic - All History Daily'[Date] <=EARLIER( 'Epic - All History Daily'[Date]))))

21120901.jpg

 

Best Regards,
Community Support Team _ Jing
If this post helps, please Accept it as Solution to help other members find it.

amitchandak
Super User
Super User

@rbangari001 , Try a new measure like

 

Sumx(Summarize(Table, Table[Work Item Id], Table[State], "_min" , min (Table[Date]) , "_max" , max(Table[Date])), datediff(_min, _max,day) +1 )



Power BI Features || Datamarts: https://youtu.be/8tskWsJTEpg || Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Time Intelligence Decoded : https://youtu.be/aU2aKbnHuWs&t=145s
Did I answer your question? Mark my post as a solution! Appreciate your Kudos !! Proud to be a Super User! !!
Dashboard of My Blogs !! Connect on Linkedin !! Subscribe to my youtube Channel !!
Want To Learn Power BI | Beginners !! Advance Concepts !! Power BI For Tableau User !!

Helpful resources

Announcements
August 1 episode 9_no_dates 768x460.jpg

The Power BI Community Show

Watch the playback when Priya Sathy and Charles Webb discuss Datamarts! Kelly also shares Power BI Community updates.

Power BI Dev Camp Session 24 without aka link and time 768x460.jpg

Ted's Dev Camp - July 28, 2022

Watch Session 24 of Ted's Dev Camp along with past sessions!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Top Solution Authors
Top Kudoed Authors