Use DAX to count any instance of name in one table that occur in a certain year in four related tables.

WilliamPHII

New Member
Joined
Aug 30, 2018
Messages
20
Hi,

I'm new to Mr. Excel, (and to DAX). My problem is that I have a name table with only a list of names. These names appear in four other tables which include dates (There are multiple occurrences of the names, and multiple dates. Not all names appear in all tables).

I'd like to use DAX to filter out all names which occur in at least one of the tables with a date in 2018 (one of the years available from the total date options). In other words, if "Bob" shows up in several of the tables but doesn't have a date in 2018 showing, he would not be in this group.

I really just need a count function that counts the instances of the names in the other four tables for 2018. Then I can run a pivot and filter out any names with 1> count.

Any help would be great!

Thanks.

William
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
I suggest a helper column (or 4, one for each table you're searching if the code gets too complex or takes too long to run). You don't say if the tables are related, so let's assume they're not.

A helper column in the name table for the info in the date tables might be:

Code:
Name in DateTable1 =IF (
    CALCULATE (
        COUNTROWS ( DateTable1 ),
        FILTER ( DateTable1, Names[Name] = DateTable1[Name] && YEAR ( DateTable1[Date] ) = 2018 )
    )
        > 0,
    "Exclude",
    "Include"
)
Then you can filter on whether to include or exclude the name.

Row filtering always trips me up... you may need to do EARLIER(Names[Name]) in the above code if DAX says it can't resolve the field value.
 
Upvote 0
I appreciate the thoughtful answer. Yes, the tables are related. You make an excellent point about using a helper column. I will look into that sometime soon here when I'm not supposed to be on the clock... :)

Thanks again for taking the time to reply.

William
 
Upvote 0

Forum statistics

Threads
1,226,225
Messages
6,189,735
Members
453,566
Latest member
ariestattle

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