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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
cs7238
Regular Visitor

How can I create a calculator that pulls values from two table visuals?

I have a data table that breaks down different mock food products by their recipes and the percent contribution of each ingredient to each the recipe. Here is a snippet of what this table looks like (I will post a screenshot of the full table at the end of this post):

BlockProduct

Product Spec Code

Spec CodeSpec DescriptionPercent ContributionLeavening AgentCategoryFormatBrandGluten FreeLeavening System
1Food Brand 1 (Plain Pancakes)1111111111Food Brand 1 (Plain Pancakes)100NPancakePlainFood Brand 1N10%: Eggs, 6%: Baking powder
1Food Brand 1 (Plain Pancakes)11111ING1Flour50N     
1Food Brand 1 (Plain Pancakes)11111ING6Milk18N     
1Food Brand 1 (Plain Pancakes)11111ING7Eggs10Y     
1Food Brand 1 (Plain Pancakes)11111ING2Sugar8N     
1Food Brand 1 (Plain Pancakes)11111ING5Vegetable oil7N     
1Food Brand 1 (Plain Pancakes)11111ING3Baking powder6Y     
1Food Brand 1 (Plain Pancakes)11111ING4Salt1N     
2Food Brand 1 (Vanilla Pancakes)2222222222Food Brand 1 (Vanilla Pancakes)100NPancakeLiquid Mix InFood Brand 1N12%: Eggs, 7%: Baking powder
2Food Brand 1 (Vanilla Pancakes)22222ING1Flour45N     
2Food Brand 1 (Vanilla Pancakes)22222ING6Milk16N     
2Food Brand 1 (Vanilla Pancakes)22222ING7Eggs12Y     
2Food Brand 1 (Vanilla Pancakes)22222ING2Sugar10N     
2Food Brand 1 (Vanilla Pancakes)22222ING3Baking powder7Y     
2Food Brand 1 (Vanilla Pancakes)22222ING5Vegetable oil6N     
2Food Brand 1 (Vanilla Pancakes)22222ING8Vanilla3N     
2Food Brand 1 (Vanilla Pancakes)22222ING4Salt1N     

 

This is what my power BI dashboard looks like right now (explanation below):

cs7238_1-1777407050511.png

The search bars at the top are text filters that will cause only their corresponding table visual (the table visual directly below) to display ingredients from the product with that product spec code. The slicer below each table lists the spec description of each ingredient in the product searched. The two slicers are synced so that both table visuals will be sliced by the one spec code selected, and only display the percent contribution for that ingredient (spec description). Here is what it looks like when I use a slicer to display only "Sugar" in the table visuals, and what the drop-down menu looks like:

cs7238_2-1777407588384.png

cs7238_3-1777407622290.png

 

I would like to create a calculator using DAX that uses the two values in those table visuals to calculate percent similarity between the two percent contribution numbers. The percent similarity formula I am using is: % similarity = ((2*(A*B))/(A+B))*100. I'd also like the calculated percent similarity to appear in a card visual below the two slicers. Finally, I think it's important to mention that the slicers are synced and there is only one data table that both of these table visuals are pulling data from.

 

As promised, here are screenshots of the full data table:

cs7238_4-1777408173714.pngcs7238_5-1777408201852.png

If there's anything you'd like clarified, please let me know and I'll do my best to explain better! Thank you so much for your help.

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

Hi @cs7238,

I was able to reproduce your scenario using sample data and achieved the expected similarity calculation.

I’ve attached the PBIX file for your reference

vsaisraomsft_0-1777455718382.png

 

Thank you.

.

View solution in original post

6 REPLIES 6
pcoley
Solution Supplier
Solution Supplier

I understand you're looking to work with ingredient percentages in your data. 
Here are two approaches:
1. **Pre-processing:** If possible, transform your data before loading it into Power BI. Split the "Percent Contribution" column into individual ingredient and percentage columns. This will make direct DAX calculations much simpler.
2. **DAX for Unpivoting (More Advanced):** If you can't pre-process, you might consider a DAX approach using `UNION` and calculated columns to unpivot your data, but this can become complex.

 


I hope this helps.
If so please Mark it as a solution.
Kudos are Welcome!
v-saisrao-msft
Community Support
Community Support

Hi @cs7238,

I was able to reproduce your scenario using sample data and achieved the expected similarity calculation.

I’ve attached the PBIX file for your reference

vsaisraomsft_0-1777455718382.png

 

Thank you.

.

Well designed ... excellent 👌

I am running into an issue where only some of the ingredients appear in the table when I use your solution. I copy-pasted all of the DAX measures/tables into my powerBI. The only way to make all ingredients show is to add "Product Spec Code" to the table visual. I set "Summarization" to "Don't summarize" for Percent Contribution and Product Spec Code so that it would display Percent Contribution and not "sum of" in the table visual, which brought back some of the ingredients but not all.

cs7238_0-1777580551687.png

 

Hi @cs7238,

Consider using a measure-based approach rather than filtering the table. You can apply the updated DAX measures provided below and use them in your table visuals instead of the Percent Contribution column.

Value A =
VAR SelectedSpec1 =
SELECTEDVALUE('Spec Selector 1'[Spec Code #1])
RETURN
CALCULATE(
MAX(RecipeData[Percent Contribution]),
RecipeData[Product Spec Code] = SelectedSpec1
)

Value B =
VAR SelectedSpec2 =
SELECTEDVALUE('Spec Selector 2'[Spec Code #2])
RETURN
CALCULATE(
MAX(RecipeData[Percent Contribution]),
RecipeData[Product Spec Code] = SelectedSpec2
)

 

Thank you.

pauliinah
Frequent Visitor

Measures never pull values from visuals, only from the data model and filter context. So even though you have two table visuals, you are still filtering the one data table. For the filter context, if the two slicers are using the same column from the data table, they form an AND condition. What you could do is create two disconnected tables for the two slicers with the spec codes and descriptions and use DAX to get the values you need. So the model would look something like this:

pauliinah_0-1777455518109.png

And the DAX measures something like this:

DEFINE
    MEASURE 'Spec Code 1'[Percent Contribution Spec 1] = VAR productspec = SELECTEDVALUE('Spec Code 1'[Product Spec Code])
VAR spec = SELECTEDVALUE('Spec Code 1'[Spec Description])
RETURN
CALCULATE(
    MAX(Data[Percent Contribution]),
    Data[Product Spec Code] = productspec,
    Data[Spec Description] = spec
)
    MEASURE 'Spec Code 2'[Percent Contribution Spec 2] = VAR productspec = SELECTEDVALUE('Spec Code 2'[Product Spec Code])
VAR spec = SELECTEDVALUE('Spec Code 2'[Spec Description])
RETURN
CALCULATE(
    MAX(Data[Percent Contribution]),
    Data[Product Spec Code] = productspec,
    Data[Spec Description] = spec
)
    MEASURE 'Data'[% Similarity] = VAR A = [Percent Contribution Spec 1]
VAR B = [Percent Contribution Spec 2]
RETURN
DIVIDE( 2 * ( A * B ), ( A + B ) )

 

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.