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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
ani_informa
Helper III
Helper III

DAX with Count

Hi

 

I have a table with data like following snap. I want to write a DAX so that I can count the number of Emails. If Email count is more than 1 then sum those numbers. For example, in below snap, adam@msn.com comes three times and matt@ol.com comes twice which is more than 1..so In following example, I want to show 5 on card ( 3 times adam + 2 times matt ). combination of PersonId and Email is always going to be unique.

 

4646.PNG

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @ani_informa 

As tested under direct query connection, you could create measures instead of calculated columns.

Measure = CALCULATE(COUNT('test1$'[PersonId]),ALLEXCEPT('test1$','test1$'[Email]))

Measure 2 = COUNTX(FILTER('test1$',[Measure]>1),[Measure])

Capture24.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
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

5 REPLIES 5
v-juanli-msft
Community Support
Community Support

Hi @ani_informa 

As tested under direct query connection, you could create measures instead of calculated columns.

Measure = CALCULATE(COUNT('test1$'[PersonId]),ALLEXCEPT('test1$','test1$'[Email]))

Measure 2 = COUNTX(FILTER('test1$',[Measure]>1),[Measure])

Capture24.JPG

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Tahreem24
Super User
Super User

Hi @ani_informa ,

 

For your requirement you just need to create one measure which count the email id.

Count = COUNT(Sheet1[Email])
 
Then take one slicer for email id and Card to show the above DAX formula.
Find the below screen shot for your reference.
 
Please give Kudos to this Efforts and accept this as a solution if it helps!
 
count.JPG
Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard

Hi Tahreen

 

I do not want to show value as per email filter.

Gordonlilj
Solution Sage
Solution Sage

Hi,

 

One way you could try and achieve this would be to first create a calculated column using something like below:

 

E-mail occurence  =
COUNTX ( FILTER (
 'Table', EARLIER ( 'Table'[Email] ) = 'Table'[Email] ),
    'Table'[Email]
)
 
Then creating a measure:
 
Count occurence > 1 =
CALCULATE( COUNT( 'Table'[Email] ),
                           FILTER( 'Table','Table'[Occurence] > 1 )
)
 
Perhaps not the most elegant solution but if i've understood you correctly than it should work
 
 

 

Thanks for your reply but I cannot use this because I am using DirectQuery Mode and not Import.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.