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
Anonymous
Not applicable

Count measure needed to keep Closed Status and remove Decommissioned Status

I have a table called Test Scripts.

 

I need a COUNT measure, which will keep a Test Script whenever the script State="Closed" and will remove the Test Script whenever the State="Decomissioned" OR Validated="Out of Scope".

 

Then, I need it to only display all the changes ref to the lastest FirstStatusChangedDate (e.g.: latest TAG changes, lastest Title changes,etc).

 


Current table:

 

Test Script IDStateValidatedTagsTitleFirstStatusChangedDate
6ClosedNot AnalysedGLS_North; IA; UFT; VistexNUSA-MS-BB02_VISTEX_BILLBACK_INDIRECT_OWNED22/02/2017 15:14
6ClosedNot StartedGLS_North; IA; UFT; VistexNUSA-MS-BB02_VISTEX_BILLBACK_INDIRECT_OWNED22/02/2017 15:14
6ClosedTicketAMS; GLS_North; IA; MATSPW31; UFT; VistexNUSA-MS-BB02_VISTEX_BILLBACK_INDIRECT_OWNED22/02/2017 15:14
6ClosedValidatedGLS_North; IA; UFT; VistexNUSA-MS-BB02_VISTEX_BILLBACK_INDIRECT_OWNED22/02/2017 15:14
6ClosedValidatedGLS_North; NA_MAT_Exec; UFT; VistexMS-NUSA-VTX_ART002_1_BB0222/02/2017 15:14
6DecomissionedNot AnalysedAMS; GLS_North; IA; MATSPW31; MATSPW32; MATSPW33; MATSPW34; UFT; VistexNUSA-MS-BB02_VISTEX_BILLBACK_INDIRECT_OWNED6/04/2020 12:55
6DecomissionedNot AnalysedAMS; GLS_North; IA; MATSPW31; MATSPW32; MATSPW33; UFT; VistexNUSA-MS-BB02_VISTEX_BILLBACK_INDIRECT_OWNED6/04/2020 12:55
8Closed GLS_North; IA; UFT; VistexMS-NUSA-VTX_ART001_1_BB0122/02/2017 15:14
8ClosedBeing TestedAMS; GLS_North; IA; MATSPW31; UFT; VistexNUSA-MS-BB01_VISTEX_BILLBACK_INDIRECT_GPO22/02/2017 15:14
8ClosedNot AnalysedGLS_North; IA; UFT; VistexNUSA-MS-BB01_VISTEX_BILLBACK_INDIRECT_GPO22/02/2017 15:14
8ClosedValidatedGLS_North; NA_MAT_Exec; UFT; VistexMS-NUSA-VTX_ART001_1_BB0122/02/2017 15:14
8DecomissionedNot AnalysedAMS; GLS_North; IA; MATSPW31; MATSPW32; MATSPW33; MATSPW34; UFT; VistexNUSA-MS-BB01_VISTEX_BILLBACK_INDIRECT_GPO6/04/2020 12:55
8DecomissionedNot AnalysedAMS; GLS_North; IA; MATSPW31; MATSPW32; MATSPW33; UFT; VistexNUSA-MS-BB01_VISTEX_BILLBACK_INDIRECT_GPO6/04/2020 12:55
9Closed GLS_North; IA; UFT; VistexMS-NUSA-VTX_ART003_1_BB0322/02/2017 15:14
9ClosedNot StartedGLS_North; IA; UFT; VistexNUSA-MS-BB03_VISTEX_BILLBACK_INDIRECT_STREET22/02/2017 15:14
9ClosedOut of ScopeAMS; GLS_North; IA; UFT; VistexNUSA-MS-BB03_VISTEX_BILLBACK_INDIRECT_STREET22/02/2017 15:14
9ClosedOut of ScopeGLS_North; IA; UFT; VistexNUSA-MS-BB03_VISTEX_BILLBACK_INDIRECT_STREET22/02/2017 15:14
9ClosedPending MKTGLS_North; IA; UFT; VistexNUSA-MS-BB03_VISTEX_BILLBACK_INDIRECT_STREET22/02/2017 15:14
9ClosedValidatedGLS_North; NA_MAT_Exec; UFT; VistexMS-NUSA-VTX_ART003_1_BB0322/02/2017 15:14
9DecomissionedOut of ScopeAMS; GLS_North; IA; MATSPW31; MATSPW32; UFT; VistexNUSA-MS-BB03_VISTEX_BILLBACK_INDIRECT_STREET15/08/2019 14:36
32DecomissionedNot AnalysedCAMBARNPPC-FICO-Export_Customer_Delivery6/02/2018 15:27
36ClosedNot AnalysedGLS_North; IA; UFT; VistexNUSA-MS-BB04_VISTEX_BILLBACK_DIRECT_GPO22/02/2017 15:14
36ClosedNot StartedGLS_North; IA; UFT; VistexMS-NUSA-VTX_ART004_1_BB0422/02/2017 15:14
36ClosedValidatedGLS_North; IA; UFT; VistexNUSA-MS-BB04_VISTEX_BILLBACK_DIRECT_GPO22/02/2017 15:14
36ClosedValidatedGLS_North; NA_MAT_Exec; UFT; VistexMS-NUSA-VTX_ART004_1_BB0422/02/2017 15:14
36DecomissionedNot AnalysedAMS; GLS_North; IA; MATSPW31; MATSPW32; MATSPW33; MATSPW34; UFT; VistexNUSA-MS-BB04_VISTEX_BILLBACK_DIRECT_GPO6/04/2020 12:51
36DecomissionedNot AnalysedAMS; GLS_North; IA; MATSPW31; MATSPW32; MATSPW33; UFT; VistexNUSA-MS-BB04_VISTEX_BILLBACK_DIRECT_GPO6/04/2020 12:51

 

What I want is to have a measure which will remove the State entries when State="Decomissioned" OR Validated="Out of Scope" and keep State="Closed".
e.g.: 
If Validated="Out of Scope", then remove this entry
If State=Decommissioned, remove this entry
If State=Closed and Validate=anything other than "Out of Scope", then keep and display the last updates (from FirstStatusChangedDate).

However, I can't use simple visual filter as my date slicer should COUNT whenever the script was Closed and then stop counting it whenever it gets decommissioned or out of scope. It's dynamic, which is why I need a measure.

So, if the script got Closed in Jan/20 and then got Decommissioned or Out of Scope in Mar/20, when the person selects the year 2020 in my slicer, it should count the script as Closed (in scope) for January, February and March (but only count once) and after March it should stop counting the script.
Which means, the measure will count as 1 script (the same script) between Jan and Mar/20.

Thanks

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

Hi @Anonymous 

Firstly lets transform the Table. I add some data in 2020 and 2019 into the table.

1.png

Then create two calculated columns in this table:

Year Column:

 

Year = YEAR('Table'[FirstStatusChangedDate])

 

Month Column:

 

Month = MONTH('Table'[FirstStatusChangedDate]).

 

Then we create two measures:

Measure1 for filtering table:

 

Filter = IF(MAX('Table'[State])="Decomissioned"||MAX('Table'[Validated])="Out of Scope",1,0)

 

Drag Filter Measure into Filters on this visual

7.png

Then select is not 1 and apply filter

3.png

Result

8.png

Measure2 for count the result:

First we need to create a new table(Slicer) use the Year Column values:

 

Slicer = VALUES('Table'[Year])

 

We can use Slicer table to create a Slicer.

6.png

Measuer2:

 

Count =

var t = FILTER('Table','Table'[State]<>"Decomissioned"&&'Table'[Validated]<>"Out of Scope")

VAR _a = SELECTEDVALUE('Slicer'[Year])

return

CALCULATE(DISTINCTCOUNT('Table'[Month]),Filter(t,[Year]=_a))

 

Lets build a card visual by Count Measure.

Now we can have a test, lets select 2020 in Slicer, result is as below:

5.png

Due to i don't know whether you will count by Title or Tag. Here I only count by month. Just like above I select 2020 in Slicer. And the month value in 2020 which state= closed and validated ≠Out of Scope is 3,1,1. So the result is 2.

If this reply still can't solve your problem please provide me with more details about what the value you will count by (Title, Tag,Month or Complex) and the visual of the result you want.

You can download the pbix file form this link:

https://qiuyunus-my.sharepoint.com/:u:/g/personal/tongzhou_qiuyunus_onmicrosoft_com/EdqAm2WcAxNCunxHy44vpEsBoOEzzTWRiahofQCGhEMKMw?e=lkZeBw

 

Best Regards,

Rico Zhou

 

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-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

Could you tell me if your problem has been solved? If it is, kindly Accept it as the solution. More people will benefit from it. Or you are still confused about it, please provide me with more details about your table ,problems or share me with your pbix file from your onedrive business.

Best Regards,

Rico Zhou

v-rzhou-msft
Community Support
Community Support

Hi @Anonymous 

Firstly lets transform the Table. I add some data in 2020 and 2019 into the table.

1.png

Then create two calculated columns in this table:

Year Column:

 

Year = YEAR('Table'[FirstStatusChangedDate])

 

Month Column:

 

Month = MONTH('Table'[FirstStatusChangedDate]).

 

Then we create two measures:

Measure1 for filtering table:

 

Filter = IF(MAX('Table'[State])="Decomissioned"||MAX('Table'[Validated])="Out of Scope",1,0)

 

Drag Filter Measure into Filters on this visual

7.png

Then select is not 1 and apply filter

3.png

Result

8.png

Measure2 for count the result:

First we need to create a new table(Slicer) use the Year Column values:

 

Slicer = VALUES('Table'[Year])

 

We can use Slicer table to create a Slicer.

6.png

Measuer2:

 

Count =

var t = FILTER('Table','Table'[State]<>"Decomissioned"&&'Table'[Validated]<>"Out of Scope")

VAR _a = SELECTEDVALUE('Slicer'[Year])

return

CALCULATE(DISTINCTCOUNT('Table'[Month]),Filter(t,[Year]=_a))

 

Lets build a card visual by Count Measure.

Now we can have a test, lets select 2020 in Slicer, result is as below:

5.png

Due to i don't know whether you will count by Title or Tag. Here I only count by month. Just like above I select 2020 in Slicer. And the month value in 2020 which state= closed and validated ≠Out of Scope is 3,1,1. So the result is 2.

If this reply still can't solve your problem please provide me with more details about what the value you will count by (Title, Tag,Month or Complex) and the visual of the result you want.

You can download the pbix file form this link:

https://qiuyunus-my.sharepoint.com/:u:/g/personal/tongzhou_qiuyunus_onmicrosoft_com/EdqAm2WcAxNCunxHy44vpEsBoOEzzTWRiahofQCGhEMKMw?e=lkZeBw

 

Best Regards,

Rico Zhou

 

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

 

amitchandak
Super User
Super User

@Anonymous , put a visual level filter and have all others like this other than date and date

 

put a viusal level filter for closed

Validated= lastnonblankvalue(Table[FirstStatusChangedDate],max(Table([Validated])))
Tags= lastnonblankvalue(Table[Tags],max(Table([Validated]))) //Title
last = lastnonblankvalue(Table[Tags],max(Table([Title]))) //Title

 

 

Or use this with all other values as not summarised

 

Measure =
VAR __id = MAX ( 'Table'[Script ID] )
VAR __date = CALCULATE ( MAX( 'Table'[FirstStatusChangedDate] ), ALLSELECTED ( 'Table' ), 'Table'[Script ID] = __id )
RETURN CALCULATE ( Count ( 'Table'[State] ), VALUES ( 'Table'[Script ID] ), 'Table'[Script ID] = __id, 'Table'[FirstStatusChangedDate] = __date )

 

Anonymous
Not applicable

No, this measure doesn't work as I need.

It is just showing the last State (last status).

What I want is to have a measure which will remove the State entries when State="Decomissioned" OR Validated="Out of Scope" and keep State="Closed".
e.g.: 
If Validated="Out of Scope", then remove this entry
If State=Decommissioned, remove this entry
If State=Closed and Validate=anything other than "Out of Scope", then keep and display the last updates (from FirstStatusChangedDate).

However, I can't use simple visual filter as my date slicer should COUNT whenever the script was Closed and then stop counting it whenever it gets decommissioned or out of scope. It's dynamic, which is why I need a measure.

So, if the script got Closed in Jan/20 and then got Decommissioned or Out of Scope in Mar/20, when the person selects the year 2020 in my slicer, it should count the script as Closed (in scope) for January, February and March (but only count once) and after March it should stop counting the script.
Which means, the measure will count as 1 script (the same script) between Jan and Mar/20.

thanks again for your help

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.