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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request 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
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.