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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Jayfemi
Helper I
Helper I

Count ifs and percentages

i am with tow  data sources and i  want to count the amount of times a name appears in each data source and then do a percentage  for example

 

Data Source 1 John Doe = 250

Data Source 2 John Doe = 4

 

in this case 4 is 1.6% of 250

 

1 ACCEPTED SOLUTION
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@Jayfemi,

Firstly, create the following measure in the first table.
Count1 = CALCULATE(COUNTA(Source1[name]),FILTER(Source1,Source1[name]="John Doe"))

Secondly, create the following measure in another  table.
Count2 = CALCULATE(COUNTA(Source2[name]),FILTER(Source2,Source2[name]="John Doe"))

Then create percent measure in the first table using dax below.
percent = [Count2]/[Count1]

If the above steps don't help, please share sample data of the two tables.

Regards,
Lydia

Community Support Team _ Lydia Zhang
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

2 REPLIES 2
v-yuezhe-msft
Microsoft Employee
Microsoft Employee

@Jayfemi,

Firstly, create the following measure in the first table.
Count1 = CALCULATE(COUNTA(Source1[name]),FILTER(Source1,Source1[name]="John Doe"))

Secondly, create the following measure in another  table.
Count2 = CALCULATE(COUNTA(Source2[name]),FILTER(Source2,Source2[name]="John Doe"))

Then create percent measure in the first table using dax below.
percent = [Count2]/[Count1]

If the above steps don't help, please share sample data of the two tables.

Regards,
Lydia

Community Support Team _ Lydia Zhang
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
GabrielSantos
Resolver I
Resolver I

Create a bridge table between your two data sources that contains a single unique value from each of the two data sources. Use this single table to create a relationship to both of your data sources.

 

If you want to do it with a specified name, you can do countrows with a calculate. 

 

It sounds like you might want to create measures similar to this:

 

[CountTable1] = Countrows(DataSource1[Name)

[CountTable2] = Countrows(DataSource2[Name)

[%InBoth] = Divide([CountTable1],[CountTable2]) >> please note that I don't know what the appropriate numerator/denominator is so please decide yourself, and if you want to only show names that occur in both data sources please try

    If( [CountTable1] && [CountTable2], Divide(x,y))

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.