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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
frdehuysser
New Member

Count Occurence of string select from 'Table A' in 'Col A' and in 'Col B' of Table B Separetly

Hi, 

I'm a new powerbi user and I'm trying to set up activity counters for mail flow.
I have a table A in which I have the reference list of my users' email addresses
And a second table B from Office 365 message trace in which I have several columns including "Sender","Recipient","Subject","MessageId"
I want to have 2 counters, the number of emails sent and the number of emails received by a user selected in the Slicer from table A.
I tried several ways based on examples found in the Forum, but I did not achieve the expected result.

I've create à measure for Count Sent_Emails By selected User: 

Sent_Emails =
var _d = SELECTEDVALUE('TableA'[My_users])
var _e = HASONEVALUE(''TableA'[My_users])
var _f = countrows(FILTER('TableB','TableB'[sender]))
Return
if (_e, if (ISBLANK(_f), 0, _f), BLANK() )

 

Any suggestions?

 

 

Table A looks like :

 

My_Users
sarah.croche@Mydomain.fr
anna.conda@Mydomain.fr
Maude.zarella@Mydomain.fr
jessica.netaufrais@Mydomain.fr

 

Table B looks like : 

senderrecipientsujetMessageID
sarah.croche@mydomain.frjessica.netaufrais@mydomain.frtest 1123456
sarah.croche@mydomain.franna.conda@mydomain.frtest 1123456
jack.celere@DomainA.comsarah.croche@mydomain.frtest 2134689
sarah.croche@mydomain.frjack.celere@DomainA.comtest 3258463
camille.honnete@DomainB.comanna.conda@mydomain.frtest 4584694
sarah.croche@mydomain.frjack.celere@DomainA.comtest 5369852
anna.conda@mydomain.frsarah.croche@mydomain.frtest 6789456
Maude.zarella@mydomain.frjack.celere@DomainA.comtest 7852741
1 ACCEPTED SOLUTION

Hi @frdehuysser ,

Simply modify the formula like this:

Sent_Emails =
COUNTROWS (
    FILTER ( 'TableB', 'TableB'[sender] IN DISTINCT ( TableA[My_Users] ) )
) + 0
Rec_Emails =
COUNTROWS (
    FILTER ( 'TableB', 'TableB'[recipient] IN DISTINCT ( TableA[My_Users] ) )
) + 0

Get the correct result:

vyanjiangmsft_0-1689838332798.png

I attach my sample below for your reference.

 

Best regards,

Community Support Team_yanjiang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
v-yanjiang-msft
Community Support
Community Support

Hi @frdehuysser ,

According to your description, here's my solution. Create two measures.

Sent_Emails =
COUNTROWS (
    FILTER ( 'TableB', 'TableB'[sender] = SELECTEDVALUE ( TableA[My_Users] ) )
) + 0
Rec_Emails =
COUNTROWS (
    FILTER ( 'TableB', 'TableB'[recipient] = SELECTEDVALUE ( TableA[My_Users] ) )
) + 0

Get the correct result:

vyanjiangmsft_0-1689756204590.png

I attach my sample below for your reference.

 

Best regards,

Community Support Team_yanjiang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Great, your formula does the job for a unique selection. On the other hand, if I select several entries from the My users table, the formula Return 0, Do you now if it's possible to display the SUM of multi selected ?
Thanks

Hi @frdehuysser ,

Simply modify the formula like this:

Sent_Emails =
COUNTROWS (
    FILTER ( 'TableB', 'TableB'[sender] IN DISTINCT ( TableA[My_Users] ) )
) + 0
Rec_Emails =
COUNTROWS (
    FILTER ( 'TableB', 'TableB'[recipient] IN DISTINCT ( TableA[My_Users] ) )
) + 0

Get the correct result:

vyanjiangmsft_0-1689838332798.png

I attach my sample below for your reference.

 

Best regards,

Community Support Team_yanjiang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.