Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Count if and lookup inside same column

Hi I am trying to calculate the distinct count of Resource ID if the it has only one status. If you look at the below table Resource ID 1 and 2 has the status "Update is installed" and "Update is required" so I am taking this disticnt count for "Non-Compliant". Other Resource IDs have only one status so they are compliant. I have no clue on how to achieve this. Please help

 

Resource IDUpdate Status
1Update is installed
2Update is installed
3Update is installed
4Update is installed
5Update is installed
5Update is installed
7Update is installed
8Update is installed
1Update is required
2Update is required

 

Result:

Compliant (Distinct Count of Resource ID)8
Non-Compliant (Distinct Count of Resource ID)2
1 ACCEPTED SOLUTION

@Anonymous 

 

Please see the attached file which uses Calculated column and MEASURE instead of CALCULATED TABLE

View solution in original post

9 REPLIES 9
Ashish_Mathur
Super User
Super User

Hi,

Create this calculated column formula and name it as Stage

=IF(CALCULATE(DISTINCTCOUNT(Data[Update Status]),FILTER(Data,Data[Resource ID]=EARLIER(Data[Resource ID])))=1,"Compliant","Not compliant")

To your visual, drag the Stage column and write this measure

Measure = DISTINCTCOUNT(Data[Resource ID])

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Zubair_Muhammad
Community Champion
Community Champion

@Anonymous 

 

Try this MEASURE

NonCompliant IDs =
COUNTROWS (
    FILTER (
        VALUES ( Table1[Resource ID] ),
        CALCULATE ( DISTINCTCOUNT ( Table1[Update Status] ) ) > 1
    )
)

 

 

Anonymous
Not applicable

@Zubair_Muhammad 

 

Any ideas please

@Anonymous 

 

Try this calculated table

Please see attached file as well

 

Calculated Table =
{
    ( "Non Compliant", COUNTROWS (
        FILTER (
            VALUES ( Table1[Resource ID] ),
            CALCULATE ( DISTINCTCOUNT ( Table1[Update Status] ) ) > 1
        )
    ) ),
    ( "Compliant", COUNTROWS ( VALUES ( Table1[Resource ID] ) ) )
}
Anonymous
Not applicable

@Zubair_Muhammad 

 

Thanks for helping again. The result is accurate. We are nearing the completion.

 

I would like to create this result as a PIE. So that if I am clicking on the Non Compliant then i should see the Resource IDs. Also I have other dimensions like City, etc., So if I select the City then this Compliant and Non-Compliant values should change accordingly. Since this is a separate Calculated Table I dont know how to achieve this.

 

Or to be simple if you add one more column to your dataset like City and name few as USA and few as UK. Now if I am using this City as drop down filter the Calculated column should change.  How to achieve this..?

Thanks in advance for your help..

@Anonymous 

 

Please see the attached file which uses Calculated column and MEASURE instead of CALCULATED TABLE

Anonymous
Not applicable

Thanks for your timely help. It worked like a charm...

I will get back to you in an hour or so.

I am out of office now
Anonymous
Not applicable

Hi,

 

But I need this like a dimension. I need a bar chart or pie chart as shown in my Post "Result". The measure is giving me the count.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors