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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
v-yangliu-msft
Community Support
Community Support

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
v-yangliu-msft
Community Support
Community Support

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

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

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.