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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
HenryJS
Post Prodigy
Post Prodigy

DAX Code: count values across two tables

Hi all,

 

I have two tables which have the same columns.

 

How can I write the below code to return values and look up against both tables?

 

Candidate Calls = calculate(DISTINCTCOUNT('Export Actions'[CandidateRef]),'Export Actions'[ActionName] in {"Call - Check In","Call - Follow Up", "Call - Proactive Approach", "Call - Update"},'Export Actions'[ActionDate] )

 

1. Export Actions

 

Export Actions - History.PNG

 

 

2. Export Actions - History

 

Export Actions.PNG

1 ACCEPTED SOLUTION
Anonymous
Not applicable

HI @HenryJS ,

You can try to use the following measure formula to get distinct count from the merged table:

 

Candidate Calls =
VAR _list =
    FILTER (
        UNION (
            SELECTCOLUMNS (
                'Export Actions',
                "UserName", [UserName],
                "ActionName", [ActionName],
                "ActionDate", [ActionDate],
                "CandidateRef", [CandidateRef]
            ),
            SELECTCOLUMNS (
                'Export Actions - History',
                "UserName", [UserName],
                "ActionName", [ActionName],
                "ActionDate", [ActionDate],
                "CandidateRef", [CandidateRef]
            )
        ),
        [ActionName]
            IN {
            "Call - Check In",
            "Call - Follow Up",
            "Call - Proactive Approach",
            "Call - Update"
        }
    )
RETURN
    COUNTROWS ( SUMMARIZE ( _list, [CandidateRef] ) )

 

Regards,

Xiaoxin Sheng

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

HI @HenryJS ,

You can try to use the following measure formula to get distinct count from the merged table:

 

Candidate Calls =
VAR _list =
    FILTER (
        UNION (
            SELECTCOLUMNS (
                'Export Actions',
                "UserName", [UserName],
                "ActionName", [ActionName],
                "ActionDate", [ActionDate],
                "CandidateRef", [CandidateRef]
            ),
            SELECTCOLUMNS (
                'Export Actions - History',
                "UserName", [UserName],
                "ActionName", [ActionName],
                "ActionDate", [ActionDate],
                "CandidateRef", [CandidateRef]
            )
        ),
        [ActionName]
            IN {
            "Call - Check In",
            "Call - Follow Up",
            "Call - Proactive Approach",
            "Call - Update"
        }
    )
RETURN
    COUNTROWS ( SUMMARIZE ( _list, [CandidateRef] ) )

 

Regards,

Xiaoxin Sheng

SteveCampbell
Memorable Member
Memorable Member

You can Union the tables in memory in the DAX. Consider using SELECTCOLUMNS if it runs slow.

Candidate Calls = 
var _uniontable = union(TableA, TableB)
RETURN
calculate(DISTINCTCOUNT(_uniontable ,'Export Actions'[ActionName] in {"Call - Check In","Call - Follow Up", "Call - Proactive Approach", "Call - Update"},'Export Actions'[ActionDate] )

 

Appreciate your Kudos
Connect with me!

Stay up to date on  linkedin-logo.png
Read my blogs on  powerbi.tips_.png



Did I answer your question? Mark my post as a solution! Proud to be a Super User!


Connect with me!
Stay up to date on  
Read my blogs on  



Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Top Solution Authors