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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply

Compare three tables, distinguish the difference from one to another

Dear experts,

 

I need to create a visual as below:

 

ID Who take a look Who actually buy
1 Yes Yes 150 (total sum that ID 1 bought) 
2 Yes Yes 120 
3 Yes Yes 341 
4 Yes Yes 220 
5 Yes  No   
6 Yes  No   
7 Yes  No   
8 Yes  No   
9 No     
10 No     
11 Yes     
12 No     

 

From 3 tables:

Table 1: A small number of IDs (unique)

ID
1
2
3
4
5
6
7
8
9
10
11
12

 

 

Table 2: the biggest data set of IDs contains some IDs from Table 1 and other IDs. There are duplicates (as everytime a particular buyer takes a look to the product, it is recorded, whether they buy or not).

ID
1
1
1
2
3
3
3
3
3
4
4
5
6
5
20
5
7
8
11
8
11

 

Table 3: includes two columns, recording every purchase from whom actually buy after taking a look. Column 1 is a subdata set from IDs in table 2. Column 2 is amount money.

ID Amount
1 100
1 50
2 120
3 341
4 190
4 30
20 400

 

I would be grateful for every solution.

 

Thank you very much!

 

2 ACCEPTED SOLUTIONS
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @BusinessAnalyst,

First, please create a relationship between the tables. In order to create a relationship in a data model in Power Pivot, at least one side of the relationship must be tied to a column that is unique in the table. The ID in table1 is unique, you can create relationship. More details about creating relationship, please review this article.

1.png

 

Then create a calculated column in table3 to get the total sum of each ID bought as the following formula and snapshot.

2.png

 

In table1, create measure look, and create another three calculated columns using the following formulas and get expected result.


Look = COUNTX(RELATEDTABLE(Table2),Table2[ID])

total buy = LOOKUPVALUE(Table3[Total],Table3[ID],Table1[ID])
Who table a look = IF(Table1[Look]>0,"Yes","No")
Who actually buy = IF(Table1[total buy]>0,"Yes","No")

3.png

If you have any question, please feel free to ask.

Best Regards,
Angelia

View solution in original post

Hi @BusinessAnalyst,

Of course, you can. Just create a calculated column and get the desired result.

Look count = COUNTX(RELATEDTABLE(Table2),Table2[ID])


1.png

Best Regards,
Angelia

View solution in original post

3 REPLIES 3
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @BusinessAnalyst,

First, please create a relationship between the tables. In order to create a relationship in a data model in Power Pivot, at least one side of the relationship must be tied to a column that is unique in the table. The ID in table1 is unique, you can create relationship. More details about creating relationship, please review this article.

1.png

 

Then create a calculated column in table3 to get the total sum of each ID bought as the following formula and snapshot.

2.png

 

In table1, create measure look, and create another three calculated columns using the following formulas and get expected result.


Look = COUNTX(RELATEDTABLE(Table2),Table2[ID])

total buy = LOOKUPVALUE(Table3[Total],Table3[ID],Table1[ID])
Who table a look = IF(Table1[Look]>0,"Yes","No")
Who actually buy = IF(Table1[total buy]>0,"Yes","No")

3.png

If you have any question, please feel free to ask.

Best Regards,
Angelia

Many thanks for your solution. I have a follow up question that I'd like to ask:
In the same visual result, is it possible to show the calculation of how many times the id repeats- to see how often he/she looks at the product and buy.

With kind regards,
Cindy

Hi @BusinessAnalyst,

Of course, you can. Just create a calculated column and get the desired result.

Look count = COUNTX(RELATEDTABLE(Table2),Table2[ID])


1.png

Best Regards,
Angelia

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.