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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

Calculating the ratio of ingredients using measures only

So I have the following problem and I need help with it using Dax measures only. The data looks like this:

RecipeIngredientCuisine
HummusChickpeasSyrian
HummusTahiniSyrian
HummusOilSyrian
HummusChickpeas

Lebanese

 

I want to calculate the ratio of ingredients to recipes depending on in how many cuisines do they appear together. 
For example: the result should first be like:

 

RecipeIngredient# Cuisines
HummusChickpeas2
HummusTahini1
HummusOil1

 

And then finally the ratio of ingredients to recipes should be 1.33 since it's the sum of cuisines divided by number of ingredients.

 

But the biggest problem is that some of these rows are duplicates since there are other columns as well. Because of that I could not simply take the distinct count of cuisine and I ended up with a ratio of 0.66 finally. I hope I am being clear enough here.

 

How could I achieve this using measures only?

Thanks in advance.

1 REPLY 1
Dangar332
Super User
Super User

Hi, @Anonymous 

 

try below code just adjust your table and column name.

result = 
var a = CALCULATE(COUNT('table 1'[Cuisine]),ALL('table 1'))
var b = CALCULATE(DISTINCTCOUNT('table 1'[Ingredient]),ALLEXCEPT('table 1','table 1'[Recipe]))
return 
divide(a,b)

 

Dangar332_0-1698484404173.png

 

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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