<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Calculating the ratio of ingredients using measures only in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-the-ratio-of-ingredients-using-measures-only/m-p/3502487#M134328</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try below code just adjust your table and column name.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 28 Oct 2023 09:13:30 GMT</pubDate>
    <dc:creator>Dangar332</dc:creator>
    <dc:date>2023-10-28T09:13:30Z</dc:date>
    <item>
      <title>Calculating the ratio of ingredients using measures only</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-the-ratio-of-ingredients-using-measures-only/m-p/3502441#M134327</link>
      <description>&lt;P&gt;So I have the following problem and I need help with it using Dax measures only. The data looks like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Recipe&lt;/TD&gt;&lt;TD&gt;Ingredient&lt;/TD&gt;&lt;TD&gt;Cuisine&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Hummus&lt;/TD&gt;&lt;TD&gt;Chickpeas&lt;/TD&gt;&lt;TD&gt;Syrian&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Hummus&lt;/TD&gt;&lt;TD&gt;Tahini&lt;/TD&gt;&lt;TD&gt;Syrian&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Hummus&lt;/TD&gt;&lt;TD&gt;Oil&lt;/TD&gt;&lt;TD&gt;Syrian&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Hummus&lt;/TD&gt;&lt;TD&gt;Chickpeas&lt;/TD&gt;&lt;TD&gt;&lt;P&gt;Lebanese&lt;/P&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to calculate the ratio of ingredients to recipes depending on in how many cuisines do they appear together.&amp;nbsp;&lt;BR /&gt;For example: the result should first&amp;nbsp;be like:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Recipe&lt;/TD&gt;&lt;TD&gt;Ingredient&lt;/TD&gt;&lt;TD&gt;# Cuisines&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Hummus&lt;/TD&gt;&lt;TD&gt;Chickpeas&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Hummus&lt;/TD&gt;&lt;TD&gt;Tahini&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Hummus&lt;/TD&gt;&lt;TD&gt;Oil&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How could I achieve this using measures only?&lt;BR /&gt;&lt;BR /&gt;Thanks in advance.&lt;/P&gt;</description>
      <pubDate>Sat, 28 Oct 2023 06:38:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-the-ratio-of-ingredients-using-measures-only/m-p/3502441#M134327</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-10-28T06:38:40Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating the ratio of ingredients using measures only</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-the-ratio-of-ingredients-using-measures-only/m-p/3502487#M134328</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;try below code just adjust your table and column name.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;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)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 28 Oct 2023 09:13:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-the-ratio-of-ingredients-using-measures-only/m-p/3502487#M134328</guid>
      <dc:creator>Dangar332</dc:creator>
      <dc:date>2023-10-28T09:13:30Z</dc:date>
    </item>
  </channel>
</rss>

