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

How to calculate how many rows match a measure in other table?

Hi,

 

I have a table 'sla' with the following structure + other columns, such as date, engineer, etc.

 

ticket_id || company || sla_ok

1            || a              || yes

2            || a              || yes

3            || a              || no

4            || b              || yes

5            || b              || no

6            || c              || yes

 

And I have a table 'companies':

company

a

b

c

d

 

And I have a measure like:

sla_% = 
total = CALCULATE(COUNT('sla'[ticket_id])

ok    = CALCULATE(COUNT('sla'[ticket_id],'sla'[sla_ok] = "yes")
return ok/total

 

Now I want to create a measure that calculates the % of companies that has at least 1 ticket and a sla_% bigger than 60%. This measure must also be dynamic to follow the slicers I have on the page (date, engineer, etc.) 

 

So I'm trying to do the following, but it's not working correctly.

 

final_measure = 

var ok = IF(CALCULATE([sla_%]) > 0.6, 1, 0)

var company_ok = sumx('companies', ok)
var company_total = calculate(distinctcount('sla'[company])

return company_ok/company_total

 

Does anyone know how to solve it, or can you explain if it's possible to do it dynamically?

1 ACCEPTED SOLUTION
MFelix
Super User
Super User

Hi @AlexandreCoutoB ,

 

Try the following measure:

 

final_measure =
VAR SLATotalTable =
    ADDCOLUMNS ( companies, "Sla%", [sla_%] )
RETURN
    DIVIDE (
        COUNTROWS ( FILTER ( SLATotalTable, [Sla%] > 0.6 ) ),
        COUNTROWS ( FILTER ( SLATotalTable, [Sla%] <> BLANK () ) )
    )

MFelix_0-1676809388412.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @AlexandreCoutoB ,

 

Try the following measure:

 

final_measure =
VAR SLATotalTable =
    ADDCOLUMNS ( companies, "Sla%", [sla_%] )
RETURN
    DIVIDE (
        COUNTROWS ( FILTER ( SLATotalTable, [Sla%] > 0.6 ) ),
        COUNTROWS ( FILTER ( SLATotalTable, [Sla%] <> BLANK () ) )
    )

MFelix_0-1676809388412.png

 

 


Regards

Miguel Félix


Did I answer your question? Mark my post as a solution!

Proud to be a Super User!

Check out my blog: Power BI em Português



Hi @MFelix , yes, it worked! Thanks!!

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.