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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
amikm
Helper V
Helper V

Calculate the ratio based on two disconnected table

Hi all, 

I need some suggestion, I got stuck for below usecase

amikm_0-1694683761348.png


this report is to compare the R12 and R6Sales between two products and then compare the ratio between R12Sales and R6Sales for both Products selected from slicer for a customer
I need to create a report like above for this I have ManagerName and AccountNumber that I can drag in a table visual. The Second and third table is showing R12Sales and R6Sales for Selected Product A and Product B, then we are calulating ratio in fourth table.

I am using below DAX for R12Sales, R6Sales
var ProductA=SELECTEDVALUE('Product '[ProductName])
R12Sales= Calculate([R12Sales], filter(Product,ProductA))

var ProductB=SELECTEDVALUE('Product '[ProductName])
R6Sales= Calculate([R6Sales], filter(Product,ProductB))

Do we really need to this in four tables or can we do in single table?

I really appreciate your help and looking forward for your thought and suggestions

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi  @amikm ,

 

You can try to add Index to both productA and productB tables, so that each row can have [Index] to act as a flag to compare, otherwise the comparison would be the total value of the two tables.

 

Here are the steps you can follow:

1. In Power Query -- Add Column – Index Column – From 1.

vyangliumsft_0-1695090652120.png

vyangliumsft_1-1695090652121.png

2. Create measure.

Measure_R16=
var _AR16=
SUMX(
    FILTER(ALL(ProductA),
    'ProductA'[Index]=MAX('ProductA'[Index])),[R16 Sales])
var _BR16=
SUMX(
    FILTER(ALL(ProductB),
   'ProductB'[Index]=MAX('ProductA'[Index])),[R16 Sales])
return
DIVIDE(_BR16,_AR16)
Measure_R6 =
var _AR6=
SUMX(
    FILTER(ALL(ProductA),
   'ProductA'[Index]=MAX('ProductA'[Index])),[R6 Sales])
var _BR6=
SUMX(
    FILTER(ALL(ProductB),
   'ProductB'[Index]=MAX('ProductB'[Index])),[R6 Sales])
return
DIVIDE(_BR6,_AR6)

3. Result:

vyangliumsft_2-1695090683486.png

Best Regards,

Liu Yang

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

Hi  @amikm ,

 

You can try to add Index to both productA and productB tables, so that each row can have [Index] to act as a flag to compare, otherwise the comparison would be the total value of the two tables.

 

Here are the steps you can follow:

1. In Power Query -- Add Column – Index Column – From 1.

vyangliumsft_0-1695090652120.png

vyangliumsft_1-1695090652121.png

2. Create measure.

Measure_R16=
var _AR16=
SUMX(
    FILTER(ALL(ProductA),
    'ProductA'[Index]=MAX('ProductA'[Index])),[R16 Sales])
var _BR16=
SUMX(
    FILTER(ALL(ProductB),
   'ProductB'[Index]=MAX('ProductA'[Index])),[R16 Sales])
return
DIVIDE(_BR16,_AR16)
Measure_R6 =
var _AR6=
SUMX(
    FILTER(ALL(ProductA),
   'ProductA'[Index]=MAX('ProductA'[Index])),[R6 Sales])
var _BR6=
SUMX(
    FILTER(ALL(ProductB),
   'ProductB'[Index]=MAX('ProductB'[Index])),[R6 Sales])
return
DIVIDE(_BR6,_AR6)

3. Result:

vyangliumsft_2-1695090683486.png

Best Regards,

Liu Yang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

lbendlin
Super User
Super User

Please provide sample data (with sensitive information removed) that covers your issue or question completely, in a usable format (not as a screenshot). Leave out anything not related to the issue.
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.