'power BI All approve columns counts

I have these data

create table #data (MilesID INT, Milestone varchar(50), Sataus varchar(50))
insert into #data values

(101 ,'Done All 20','A-approved completed'), (101 ,'Done All 20','CA-approved completed'),
(101 ,'Done All 20','DC-approved completed'), (102 ,'well done 25','QA-approved Done'),
(102 ,'well done 25','DV-approved Accept'), (103 ,'Done 18','Incomplete'),
(103 ,'Done 18','CA-approved completed'), (103 ,'Done 18','DC-approved completed'),
(104 ,'Late 3','Awaiting'),(104 ,'Late 3','DC-approved completed')
select
*
from #data
drop table #data

enter image description here

I want to be able to check if MilesID are the same and The status contain approved in the same MilesID I want to count that as 1. for example. MilesID 101 and 102 in their status they all contain Approved, but 103 and 104 are not because all the status do not contain approved

I tired this DAX

 Measure = 
CALCULATE(DISTINCTCOUNT(Data[MilesID]),     
   FILTER(Data,if(CONTAINSSTRING(Data[Status],
    "approved")=TRUE(),"approved",BLANK())<> BLANK() ))

The Output is 4 but my desired result should be 2

I also tried

FinalCheck = var one =COUNT(Data[MilesID])
             var two= CALCULATE(COUNT(Data[Status]),
             FILTER(Data,CONTAINSSTRING(Data[Status],"approved")=TRUE()))
              var three= IF(one - two =0,1,0)
              return
              three

This one returns 0 as answer



Solution 1:[1]

Please try this one:

Measure = DISTINCTCOUNT(Data[MilesID]) - CALCULATE(DISTINCTCOUNT(Data[MilesID]), NOT(CONTAINSSTRING(Data[Status],"approved")))

Three steps to find the answer:

  1. find how many distinct MilesID in this Data table.
  2. find how many distinct MilesID with status that does not contain "approved"
  3. step 1 - step2

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sherrrry