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
DarioSantos
Frequent Visitor

Percentage with 2 tables

Hi,

 

I have 2 tables with traffic data from 3 sites.

One with data by day, device and total PV on site.

datasitepvdevice
10-outa897238destkop
10-outa213124mobile
10-outb324324destkop
10-outb2342422mobile
10-outc3242342destkop
10-outc2342332mobile
09-outa7892316destkop
09-outa21469mobile
09-outb12634912destkop
09-outb12839mobile
09-outc12764381destkop
09-outc128498

mobile

 

Other with day, source, site, device and PV.

datasourcesitepvdevice
10-outab198destkop
10-outab219mobile
10-outac132destkop
10-outac453mobile
10-outba324destkop
10-outba423mobile
10-outbc321destkop
10-outbc43mobile
10-outca321destkop
10-outca43mobile
10-outcb4destkop
10-outcb56mobile
09-outab1destkop
09-outab213mobile
09-outac324destkop
09-outac3456mobile
09-outba4destkop
09-outba56mobile
09-outbc32destkop
09-outbc8mobile
09-outca8destkop
09-outca4mobile
09-outcb6destkop
09-outcb2mobile

 

I need have a % of traffic on one site came from other site.

For example % of traffic on site A came from site B. on this case (324+423+4+56)/(897238+213124+7892316+21469

 

How i can make this mesure?

 

I try create a aux column in 2 tables with day&site&device and related this aux column but with the mesure calculate(sum(table1[PV])/sum(table2[PV])) the power bi sum all valueson table 2 and not only  the values with same parameters.

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

Hi @DarioSantos,

 

According to your description, you want to get result about “total pv of same source and same site in table 2” / “total pv of same site in table 1”, right?

 

If it is a case, you can refer to below measure to achieve your requirement:

 

Measure:
Percent =
var currSite=LASTNONBLANK(Sheet2[site],Sheet2[site])
var currSource=LASTNONBLANK(Sheet2[source],Sheet2[source])
return
SUMX(FILTER(ALL(Sheet2),Sheet2[site]=currSite&&Sheet2[source]=currSource),Sheet2[pv])/SUMX(FILTER(ALL(Sheet1),Sheet1[site]=currSite),Sheet1[pv])

 

Result visual:
 Capture4.PNG

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

2 REPLIES 2
v-shex-msft
Community Support
Community Support

Hi @DarioSantos,

 

According to your description, you want to get result about “total pv of same source and same site in table 2” / “total pv of same site in table 1”, right?

 

If it is a case, you can refer to below measure to achieve your requirement:

 

Measure:
Percent =
var currSite=LASTNONBLANK(Sheet2[site],Sheet2[site])
var currSource=LASTNONBLANK(Sheet2[source],Sheet2[source])
return
SUMX(FILTER(ALL(Sheet2),Sheet2[site]=currSite&&Sheet2[source]=currSource),Sheet2[pv])/SUMX(FILTER(ALL(Sheet1),Sheet1[site]=currSite),Sheet1[pv])

 

Result visual:
 Capture4.PNG

 

Regards,
Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.
Anonymous
Not applicable

I think your challenges have to do w/ the way you "shaped" your data.  My first thought was "can't we combine these 2 tables into 1?" -- and I still have that question.  If that doesn't make sense, I suspect it will help to have some separate lookup tables, for site/date/device... that you can link to BOTH of your tables.

 

Ignoring that, ... 

 

Raw % := DIVIDE(SUM(Table1[PV]),Sum(Table2[PV]))

Filltered % := CALCULATE([Raw %], FILTER(Table2, CONTAINS(Table1, Table1[site], Table2[site], Table1[device], Table2[device]))

 

I totally didn't test that, but it makes sense to me at least 🙂  Filter table 2, down to just where that rows site/device are in Table 1's current context.

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.