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
Anonymous
Not applicable

Getting attach rates - Division of 2 counts from 2 different tables

Hi, I'm new to Power BI. I have 2 tables.

 

Table 1 shows number of people entering a supermarket, who bought apples.

Table 2 shows number of people who entered the supermarket. They could have bought anything.

 

What I want is to take Table 1, on a daily basis, take the number of people (count) who were in Table 1, and divide that count by the number of people (another count) who went to the supermarket from Table 2.

 

What I want is to see out of the number of people who went to the supermarket, what percentage bought apples, and have that percentage split by date.

 

Table 1

DAYPERSONGood
1Person 1Apples
1Person 2Apples
2Person 3Apples
2Person 4

Apples

 

Table 2

DAYPERSONGoods
1JohnApples
1SarahCereal
1MichaelBananas
2JohnPork
1 ACCEPTED SOLUTION

Hi,

Create a Table with 2 entries - 1 and 2.  Build a relationship from the Day column of both your Tables to the Day column of this new Table.  In your visual, drag the Day column from this new Table.  Write these measures

People buying apples = CALCULATE(COUNTROWS(Table1),Table1[Good]="Apples")

People visiting = COUNTROWS(Table2)

% of people buying apples = [People buying apples]/[People visiting]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Why does the Person column of the two Tables not match.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

That's because I wanted to put emphasis on the person's names not matching. I want the number of people who bought apples divided by the number of people who entered the store on Day 1 or Day 7 etc.


@Ashish_Mathur wrote:

Hi,

Why does the Person column of the two Tables not match.


 

Hi,

Create a Table with 2 entries - 1 and 2.  Build a relationship from the Day column of both your Tables to the Day column of this new Table.  In your visual, drag the Day column from this new Table.  Write these measures

People buying apples = CALCULATE(COUNTROWS(Table1),Table1[Good]="Apples")

People visiting = COUNTROWS(Table2)

% of people buying apples = [People buying apples]/[People visiting]

Hope this helps.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
Anonymous
Not applicable

Should the relationship be Many to Many? Also, should cross filter direction be both or single direction?

Also can I write what you did as one measure, with the division taking place in it?


@Ashish_Mathur wrote:

Hi,

Create a Table with 2 entries - 1 and 2.  Build a relationship from the Day column of both your Tables to the Day column of this new Table.  In your visual, drag the Day column from this new Table.  Write these measures

People buying apples = CALCULATE(COUNTROWS(Table1),Table1[Good]="Apples")

People visiting = COUNTROWS(Table2)

% of people buying apples = [People buying apples]/[People visiting]

Hope this helps.


 

Hi,

It should be Many to 1, Single.  Try this single measure

=CALCULATE(COUNTROWS(Table1),Table1[Good]="Apples")/COUNTROWS(Table2)


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

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.