DAX counting rows driving me mad

dmarc

New Member
Joined
Jan 27, 2015
Messages
1
Hi,

I'm trying to learn DAX and at the moment its driving me mad :)

I have two tables moved into the data model

d_people (list of people details including their location code)
d_locations (unique list of building names to location codes)

in d_people there is a field loc_code

In d_locations there is a field loc_code and building_name

I've linked the two loc_codes in the mode.

In the d_locations table i'm trying to add a calculated formula that simply counts the number of people in each building,

e.g

loc code,building name, sum of people in that building

I thought

=COUNTROWS(d_people[Loc_code])

would work, but it doesnt

help please :)
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
You should be able to make a measure like the one bellow where d_people is your column name for people. Then make a pivot table and use this measure in the values.

CountPeople:=COUNTA(d_people[d_people])
 
Upvote 0
Give this a glance and see if it helps: Calculated Fields vs Calculated Columns | Tiny Lizard

COUNTROWS shoudl work fine.. though it takes a table (d_people) not a column (d_people[loc_code]). The measure will be dynamically evaluated at runtime to always be correct for the context. So, if you have a filter on a certain location (say you drop location on rows of a pivot table), then the COUNTROWS would only return those rows in that filter context (eg, at that location).
 
Upvote 0

Forum statistics

Threads
1,224,065
Messages
6,176,169
Members
452,710
Latest member
mrmatt36

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top