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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
rbhole
Frequent Visitor

Counting number of States in a column using unique WorkItemId

I want to count states from column. My data model as below,

WorkItemIdStateStateChangeDateColumn 2NewActiveQA ReadyClosedDone
87937New02-05-2022 12:5102-05-2022 12:51     
87937Done16-05-2022 06:5702-05-2022 12:51    Done
87937Active17-05-2022 00:1302-05-2022 12:51 Active   
87937New18-05-2022 13:2102-05-2022 12:51New    
87937QA Ready21-05-2022 04:2302-05-2022 12:51  QA Ready  
87937New23-05-2022 17:3002-05-2022 12:51New    
87937Active13-06-2022 14:4302-05-2022 12:51 Active   

Note : I missed to enter Column kindly look it into expected output model.

In above model I filter only specific workitemid (of course in my model there is so many workitemid's).

I used to write DAX query to create other columns like New, Active, QA Ready, Closed, Done

 

Column 2 = CALCULATE (
    MIN ( History[StateChangeDate] ),
    ALLEXCEPT ( History, History[WorkItemId] )
)
New = if (CONTAINSSTRING(History[column],"New") && History[StateChangeDate] <> History[Column 2], "New" , "")
Active = if (CONTAINSSTRING(History[column],"Active") && History[StateChangeDate] <> History[Column 2], "Active" , "")
.
.
Done = if (CONTAINSSTRING(History[column],"Done") && History[StateChangeDate] <> History[Column 2], "Done" , "")
 
Column = CONCATENATE(History[WorkItemId], CONCATENATE(History[State], History[StateChangeDate]))
 
But I want to count each state, i expecting output like below,
 
WorkItemIdStateStateChangeDateColumnColumn 2NewActiveQA ReadyClosedDone
87937New02-05-2022 12:5187937New5/2/2022 12:51:50 PM02-05-2022 12:5122101
87937Done16-05-2022 06:5787937Done5/16/2022 6:57:01 AM02-05-2022 12:5122101
87937Active17-05-2022 00:1387937Active5/17/2022 12:13:46 AM02-05-2022 12:5122101
87937New18-05-2022 13:2187937New5/18/2022 1:21:38 PM02-05-2022 12:5122101
87937QA Ready21-05-2022 04:2387937QA Ready5/21/2022 4:23:21 AM02-05-2022 12:5122101
87937New23-05-2022 17:3087937New5/23/2022 5:30:45 PM02-05-2022 12:5122101
87937Active13-06-2022 14:4387937Active6/13/2022 2:43:42 PM02-05-2022 12:5122101

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @rbhole ,

Here are the steps you can follow:

1. Create measure.

New_Measure =
COUNTX(FILTER(ALL('Table'),
'Table'[New]<>BLANK()),[New])

Active_Measure =
COUNTX(FILTER(ALL('Table'),
'Table'[Active]<>BLANK()),[New])
Q Ready_Measure =
COUNTX(FILTER(ALL('Table'),
'Table'[QA Ready]<>BLANK()),[New])
Closed_Measure =
var _close=
COUNTX(FILTER(ALL('Table'),
'Table'[Closed]<>BLANK()),[New])
return
IF(
    _close = BLANK(),0,_close)
Done_Measure =
COUNTX(FILTER(ALL('Table'),
'Table'[Done]<>BLANK()),[New])

2. Result:

vyangliumsft_0-1658801758049.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

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

2 REPLIES 2
Anonymous
Not applicable

Hi  @rbhole ,

Here are the steps you can follow:

1. Create measure.

New_Measure =
COUNTX(FILTER(ALL('Table'),
'Table'[New]<>BLANK()),[New])

Active_Measure =
COUNTX(FILTER(ALL('Table'),
'Table'[Active]<>BLANK()),[New])
Q Ready_Measure =
COUNTX(FILTER(ALL('Table'),
'Table'[QA Ready]<>BLANK()),[New])
Closed_Measure =
var _close=
COUNTX(FILTER(ALL('Table'),
'Table'[Closed]<>BLANK()),[New])
return
IF(
    _close = BLANK(),0,_close)
Done_Measure =
COUNTX(FILTER(ALL('Table'),
'Table'[Done]<>BLANK()),[New])

2. Result:

vyangliumsft_0-1658801758049.png

If you need pbix, please click here.

 

Best Regards,

Liu Yang

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

lbendlin
Super User
Super User

Your description is not clear to me.  Please describe in more details an with better examples what you are trying to achieve. 

 

A field change table usually has this format

 

Date | Field Name | Old Value | New Value

 

You may need to unpivot your data to bring it into that format.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.