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

Measure with filter and 2 conditions on one table

Hi and thanks for any help, it greatly appreciated.
 
I am trying to divide the following using a measure:
 
Count of control ids marked as BOTH of the following conditions from the controls table. controls[Control_classification] = "Mgmt" where controls[mrc_control] also = "Y"
That count of control ids then divided by the total count of control id's where controls[mrc_control] = "Y"
 
 
This is where I'm at but not sure how to add in controls[mrc_control] = "Y" to the first portion of my division.
 
% Of MRC Controls = DIVIDE(COUNTX(FILTER(Controls,controls[control_classification] = "Mgmt"),controls[id]), COUNTX(FILTER(Controls,controls[mrc_control] = "Y"),controls[id]))
 
Right now my measure is just dividing control ids marked as mgmt by control ids marked as mrc_control
 
1 ACCEPTED SOLUTION
v-yanjiang-msft
Community Support
Community Support

Hi @tcouey ,

You are missing a condition in your formula, modify it like this:

% Of MRC Controls =
DIVIDE (
    COUNTX (
        FILTER (
            Controls,
            controls[control_classification] = "Mgmt"
                && controls[mrc_control] = "Y"
        ),
        controls[id]
    ),
    COUNTX ( FILTER ( Controls, controls[mrc_control] = "Y" ), controls[id] )
)

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

Hi @tcouey ,

You are missing a condition in your formula, modify it like this:

% Of MRC Controls =
DIVIDE (
    COUNTX (
        FILTER (
            Controls,
            controls[control_classification] = "Mgmt"
                && controls[mrc_control] = "Y"
        ),
        controls[id]
    ),
    COUNTX ( FILTER ( Controls, controls[mrc_control] = "Y" ), controls[id] )
)

I attach my sample below for reference.

 

Best Regards,
Community Support Team _ kalyj

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

speedramps
Super User
Super User

Assume you want answer in card .

 

Answer =

 

// create 2 subsets

 

VAR subsetMGMTY = 
FILTER(tablename,
control_classification = "MGMTY" &&
mrc_control= "Y"
)

VAR subsetY = 
FILTER(tablename,
mrc_control= "Y"
)

RETURN
// get your answer

DIVIDE(
COUNTROWS(subsetMGMTY),
COUNTROWS(subsetY)
)

 

Drop the measure into a card visual and format the appearance.

 

Please click thumbs up and accept as solution buttons. Thanks 😀

speedramps
Super User
Super User

Please can you provide some example data in a table format (not a screen shot)

and an example of the desired output with a better description so we can help you. Thank you
Hide any private date. 

In the "controls" table below, we have columns for id mrc_control, and control_classification. I need to divide the total count of ids where control_classification = MGMT and mrc_control= Y, by the total count of ids where MRC_Control = Y. 

 

In the example table below, I would have one divided by 3, since I have one ID that is Y for mrc_control, and also MGMT for control_classification, and I have 3 total ids marked Y for mrc_control. My end result would be 33% which is what I am looking for. 

 

idmrc_controlcontrol_classification
1YMGMT
2YExec
3YExec
4NBusiness
5NMGMT
6NBusiness

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.