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
MgLina
Frequent Visitor

If contain two values then return

Hi Forum,

 

I am here again to ask help, 

 

Now i have a table with columns like below:

PartNoStepStatus
AAAStep1In time
AAAStep1Delay
AAAStep2Completed
BBBStep1In time
BBBStep1Completed

 

And i want to count the number of "Delay" and "In time" per PartNo and per Step. But the difficuly is i want: if status for the same PartNo and the same Step contain "Delay", then just count "1" for Delay, and if status for the same PartNo and the same Step contain "Completed" or "In time", then count "1" for In time.

 

For example, for the table i have here, the result of count will be:

PartNoStepCount_DelayCount_InTime
AAAStep11 
AAAStep2 1
BBBStep1 1
    
    

 

I try to use the Measure solution below, but it doesn't work well. And i don't understand why.

 

 

 

I create a measure to return one Status per part

 

StatusPerPart = 
var calc=CALCULATE(DISTINCTCOUNT('Table 2'[PartNo]);
filter('Table 2';
'Table 2'[Status]="Delay"))
Return
If(calc=1;"Delay";"In time")

 

After, i create a new measure to count the Status,

Count_InTime = countrows(filter(Table 2;Table 2[StatusPerPart]="In time"))
Count_Delay = countrows(filter(Table 2;Table 2[StatusPerPart]="Delay"))

 

 

 

Thank you!

1 REPLY 1
daxer-almighty
Solution Sage
Solution Sage

[# In Time] =
CALCULATE(
    COUNTROWS( T ),
    KEEPFILTERS( T[Status] = "in time" )
)

[# Delay] =
CALCULATE(
    COUNTROWS( T ),
    KEEPFILTERS( T[Status] = "delay" )
)

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.

Top Solution Authors