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

The ultimate Microsoft Fabric, Power BI, Azure AI & SQL learning event! Join us in Las Vegas from March 26-28, 2024. Use code MSCUST for a $100 discount. Register Now

Reply
Anonymous
Not applicable

Count with Multiple Conditions and Multiple Column Referenced

Hello,

 

I'm currently stumped on a DAX formula, which I need to count the number of entries in a column (let's call it Rule).

I need it to be filtered for the following conditions which are contained in this same table already (table 1);

- [Status] = "Active"

- [Condition] = "Performing As Expected"

It also need to filter for another condition, contained in another table (table 2), which has a relationship to table 1

- [PercentageBin] = "81-90%" or [PercentageBin] = "91-100%"

 

I want this count to be able to be shown in a Card.

 

Currently, I have the following DAX, but the Card is showing as (Blank):

 

Count of Rule for Active =
             CALCULATE(
                COUNT('Table1'[Rule]),
                  FILTER('Table1',
                           'Table1'[Status] = "Active" && 'Table1'[Condition] = "Performing As Expected"),
                  FILTER('Table2',
                           'Table2'[PercentageBin] = "81-90%" || 'Table2'[PercentageBin] = "91-100%")
)
 
Any help would be greatly appreciated!
6 REPLIES 6
Ashish_Mathur
Super User
Super User

Hi,

 

Does this measure work?

=CALCULATE(COUNT('Table1'[Rule]),'Table1'[Status] = "Active",'Table1'[Condition] = "Performing As Expected"),FILTER('Table2','Table2'[PercentageBin] = "81-90%" || 'Table2'[PercentageBin] = "91-100%"))


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-lid-msft
Community Support
Community Support

Hi @Anonymous ,

 

How about the result after you follow the suggestions mentioned in my original post?Could you please provide more details about it If it doesn't meet your requirement?


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Greg_Deckler
Super User
Super User

Try using CALCULATETABLE and put in your conditions then use COUNTROWS to count the resulting table.

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi Greg,

 

How can I use CALCULATETABLE to reference a column in a different table? I can only get CALCULATETABLE to reference Table1, but not Table 2.

Anonymous
Not applicable

I've now tried the following:

Count of Rule for Active = 
COUNTROWS (
    CALCULATETABLE ('Table1',
    FILTER('Table1',
        'Table1'[Status] = "Active"),
    FILTER('Table1',
        'Table1'[Condition] = "Perfoming As Expected"),
    FILTER('Table2',
        OR('Table2'[PercentageBin] = "81-90%",
            'Table2'[PercentageBin] = "91-100%")
        )
    )
)

 

Still showing (Blank) when I dragged this Measure into a Card.

I'm not if this affects it, but I also have other columns like [Region] and [Country] in Table 1, which I have Slicer created for. Do I need to adjust my DAX to include reference to [Country] and [Region]?

Hi @Anonymous ,

 

Based on my test, your formula works fine on our sample table, could you please describe the relationship between two tables if it does not contain any confidential information?

 

16.jpg17.jpg

 


Best regards,

 

Community Support Team _ Dong Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Fabric Community Conference

Microsoft Fabric Community Conference

Join us at our first-ever Microsoft Fabric Community Conference, March 26-28, 2024 in Las Vegas with 100+ sessions by community experts and Microsoft engineering.

February 2024 Update Carousel

Power BI Monthly Update - February 2024

Check out the February 2024 Power BI update to learn about new features.

Fabric Career Hub

Microsoft Fabric Career Hub

Explore career paths and learn resources in Fabric.

Fabric Partner Community

Microsoft Fabric Partner Community

Engage with the Fabric engineering team, hear of product updates, business opportunities, and resources in the Fabric Partner Community.