cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
dididing2001
Frequent Visitor

Divide two columns from different tables

Hello everyone, currently I have two tables: table 1 and table 2 in Power BI

Table 1:

Date

Column A

01/01

120

02/01

34

03/01

90

04/01

109

 

Table 2:

Date

Column B

01/01

200

02/01

103

03/01

270

04/01

300

 

These tables are made in Power BI after I dragged two fields for each one.

For table 1, they are the "Date" column and column A (which is the count of "True" values for each day).

Date

Column C

01/01

True

01/01

False

01/01

True

02/01

True

03/01

True

03/01

True

04/01

True

04/01

False

04/01

False

 

Table 2 is made by counting the number of clicks for each day

What I want to do is: Column A divided by Column B (A/B for short) for each day and I will use that result to draw a graph. What can I do to achieve this?

 

Thanks for your help!

1 ACCEPTED SOLUTION
ryan_mayu
Super User
Super User

@dididing2001 

you can create a date table and create relationships with table 1 and table 2

Then create a measure

Measure = 
VAR _1=CALCULATE(COUNTROWS(Table1),FILTER(Table1,Table1[ColumnC]=TRUE()))
VAR _2=sum(Table2[click])
return _1/_2

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

8 REPLIES 8
NidhiBhusari
Helper III
Helper III

Hi @dididing2001 ,

You can use measure 

Measure = DIVIDE(SUM('Table A'[Column A]),SUM('Table B'[Column B]))
ryan_mayu
Super User
Super User

@dididing2001 

you can create a date table and create relationships with table 1 and table 2

Then create a measure

Measure = 
VAR _1=CALCULATE(COUNTROWS(Table1),FILTER(Table1,Table1[ColumnC]=TRUE()))
VAR _2=sum(Table2[click])
return _1/_2

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu Thanks a lot for your help! Your method works like a charm for me!

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




@ryan_mayu Unfortunately, after checking the result, I'm afraid that the division didn't work well. I attached an image and my file below for your reference.Screenshot 2021-09-14 170607.png

The conversion rate on 01/11/2019 is 0.7, which is 412/590. Meanwhile, what I want is the result of 412/2198. I cannot figure out the problem in this calculation. 

@dididing2001 

you need to imporve the data model, since the relationship between date table and two fact tables are inactive. I have deleted all the rest relationships. you can re-create the relationship. However, I still think you can simplify the data model.

pls see the attachment below.





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




The conversion rate works now. Your advice helps me a lot when it comes to data modelling. Thanks a lot!

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors