Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
So I have the following problem and I need help with it using Dax measures only. The data looks like this:
Recipe | Ingredient | Cuisine |
Hummus | Chickpeas | Syrian |
Hummus | Tahini | Syrian |
Hummus | Oil | Syrian |
Hummus | Chickpeas | 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:
Recipe | Ingredient | # Cuisines |
Hummus | Chickpeas | 2 |
Hummus | Tahini | 1 |
Hummus | Oil | 1 |
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.
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)
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
13 | |
12 | |
11 | |
11 | |
8 |