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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
ghe7549
Helper III
Helper III

count ifs

I am trying to count the number of floors per building per facility.  I am using two measures to get this but it is not working

Facility Count = COUNTROWS('public facilities')
CALCULATE('Measure Table'[Facility Count],'public buildings'[id],'public floors'[id])

ghe7549_0-1608319753064.png

Any help would be greatly appreciated.

 

1 ACCEPTED SOLUTION

@ghe7549  This is because you have [Floor] still in the table. A couple of things you can do, either use a matrix visual instead to get the subtotals;

[Count of Floors] in Values

[Facility] in Rows

[Building] in Rows

[Floor] in Rows

Expand down to all levels using the double connected arrows (looks like a fork kind of) at top of matrix.

 

or update your measure:

 

Count of All Floors = CALCULATE(COUNTA('public facilities'[name]) , ALL('public facilities'[floor]))


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

4 REPLIES 4
ghe7549
Helper III
Helper III

@AllisonKennedy   I created the measure count of floor ( COUNTA('public facilities'[name]) ).  I am still not geting the floors to total up.  If you look at the first one there is 2 garages with 6 floors each.  I am needing it to be North Garage 6 floors and West Garage 6 Floors.

ghe7549_0-1608560690946.png

 

@ghe7549  This is because you have [Floor] still in the table. A couple of things you can do, either use a matrix visual instead to get the subtotals;

[Count of Floors] in Values

[Facility] in Rows

[Building] in Rows

[Floor] in Rows

Expand down to all levels using the double connected arrows (looks like a fork kind of) at top of matrix.

 

or update your measure:

 

Count of All Floors = CALCULATE(COUNTA('public facilities'[name]) , ALL('public facilities'[floor]))


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

AllisonKennedy
Super User
Super User

@ghe7549  The countifs in DAX comes down to how you use it, if you want to count number of floors, simply create a measure: 

 

Count of Floors = COUNTA('public facilities'[name]) 

 

Then put this in a table or matrix visual. If using a matrix, put:

[Count of Floors] in Values

[Facility] in Rows

[Building] in Rows

 

If using a table, just put them in this order:

[Facility]

[Building]

[Count of Floors]

 

If you want distinct count, use @camargos88  formula. 

 

You can also use the COUNTROWS formula you have already created if you want to include blank values in your count.

 

Hope that makes sense?


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

camargos88
Community Champion
Community Champion

@ghe7549 ,

 

Have you tried DISTINCTCOUNT('public facilities'[name]) ?



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

Proud to be a Super User!



Helpful resources

Announcements
July 2024 Power BI Update

Power BI Monthly Update - July 2024

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

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

Top Solution Authors