<?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 Need equivalent of FOR loop to iterate over multiple table columns in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-equivalent-of-FOR-loop-to-iterate-over-multiple-table/m-p/2745514#M84556</link>
    <description>&lt;P&gt;I am working with multi-year vendor sales data, and I'd like to compute how vendor market share changes over time for a given mix of products. The logic goes like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) For each vendor and year, compute their market share as:&lt;BR /&gt;Market Share = DIVIDE( [Revenue], CALCULATE([Revenue], ALL(Vendors[Vendor])), 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) For each vendor and year, compute their year-over-year market share as:&lt;BR /&gt;Market Share YoY =&lt;BR /&gt;VAR currentYeartMS = [Market Share]&lt;BR /&gt;VAR priorYearMS = CALCULATE([Market Share], SAMEPERIODLASTYEAR('Date'[Date]))&lt;BR /&gt;RETURN&lt;BR /&gt;IF(priorYearMS = 0, 0, currentYeartMS - priorYearMS)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) For each vendor, create a market share distance index. I don't know how to do this, but conceptually it is:&lt;BR /&gt;MS Index =&lt;BR /&gt;VAR overallIndex = 0&lt;BR /&gt;VAR vendorIndex = 0&lt;BR /&gt;// For each vendor over all years&lt;BR /&gt;&amp;nbsp; &amp;nbsp; vendorIndex = (1 / NumYears) * SQRT(SUM([Market Share YoY]^2))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; overallIndex = overallIndex + vendorIndex&lt;BR /&gt;&amp;nbsp; &amp;nbsp; next(vendor)&lt;BR /&gt;RETURN&lt;BR /&gt;overallIndex&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The index should be computed for each product. It is a scalar value&amp;nbsp;based on the current filter context.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a sample .pbix file. On the 'Revenue &amp;amp; Market Share' page are a matrix table with the values of Revenue, Market Share, and Market Share YoY by vendor and by year, along with slicers for product, region, and vendor. There is also a 'Product Table' page, which is where I would like to display the MS Index values for each row of the product matrix table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a link to my data .pbix sample file:&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!AgIj2L_vt8WrhtYttYRGah5VTb5sUQ?e=xkEhZc" target="_blank" rel="noopener"&gt;tstData.pbix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any and all help!&lt;/P&gt;</description>
    <pubDate>Sun, 04 Sep 2022 17:50:35 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2022-09-04T17:50:35Z</dc:date>
    <item>
      <title>Need equivalent of FOR loop to iterate over multiple table columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-equivalent-of-FOR-loop-to-iterate-over-multiple-table/m-p/2745514#M84556</link>
      <description>&lt;P&gt;I am working with multi-year vendor sales data, and I'd like to compute how vendor market share changes over time for a given mix of products. The logic goes like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1) For each vendor and year, compute their market share as:&lt;BR /&gt;Market Share = DIVIDE( [Revenue], CALCULATE([Revenue], ALL(Vendors[Vendor])), 0)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;2) For each vendor and year, compute their year-over-year market share as:&lt;BR /&gt;Market Share YoY =&lt;BR /&gt;VAR currentYeartMS = [Market Share]&lt;BR /&gt;VAR priorYearMS = CALCULATE([Market Share], SAMEPERIODLASTYEAR('Date'[Date]))&lt;BR /&gt;RETURN&lt;BR /&gt;IF(priorYearMS = 0, 0, currentYeartMS - priorYearMS)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;3) For each vendor, create a market share distance index. I don't know how to do this, but conceptually it is:&lt;BR /&gt;MS Index =&lt;BR /&gt;VAR overallIndex = 0&lt;BR /&gt;VAR vendorIndex = 0&lt;BR /&gt;// For each vendor over all years&lt;BR /&gt;&amp;nbsp; &amp;nbsp; vendorIndex = (1 / NumYears) * SQRT(SUM([Market Share YoY]^2))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; overallIndex = overallIndex + vendorIndex&lt;BR /&gt;&amp;nbsp; &amp;nbsp; next(vendor)&lt;BR /&gt;RETURN&lt;BR /&gt;overallIndex&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The index should be computed for each product. It is a scalar value&amp;nbsp;based on the current filter context.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Below is a sample .pbix file. On the 'Revenue &amp;amp; Market Share' page are a matrix table with the values of Revenue, Market Share, and Market Share YoY by vendor and by year, along with slicers for product, region, and vendor. There is also a 'Product Table' page, which is where I would like to display the MS Index values for each row of the product matrix table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here's a link to my data .pbix sample file:&lt;/P&gt;&lt;P&gt;&lt;A href="https://1drv.ms/u/s!AgIj2L_vt8WrhtYttYRGah5VTb5sUQ?e=xkEhZc" target="_blank" rel="noopener"&gt;tstData.pbix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any and all help!&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2022 17:50:35 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-equivalent-of-FOR-loop-to-iterate-over-multiple-table/m-p/2745514#M84556</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-04T17:50:35Z</dc:date>
    </item>
    <item>
      <title>Re: Need equivalent of FOR loop to iterate over multiple table columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-equivalent-of-FOR-loop-to-iterate-over-multiple-table/m-p/2746158#M84581</link>
      <description>&lt;P&gt;If nobody answers your question for a long time, it most likely means people have a hard time understanding what you really want. Please try to rephrase your question in simpler terms or have a look at &lt;A href="https://community.powerbi.com/t5/DAX-Commands-and-Tips/How-to-Get-Your-Question-Answered-Quickly/td-p/1626726" target="_blank" rel="noopener"&gt;&lt;STRONG&gt;this&lt;/STRONG&gt;&lt;/A&gt;.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2022 15:55:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-equivalent-of-FOR-loop-to-iterate-over-multiple-table/m-p/2746158#M84581</guid>
      <dc:creator>daXtreme</dc:creator>
      <dc:date>2022-09-04T15:55:32Z</dc:date>
    </item>
    <item>
      <title>Re: Need equivalent of FOR loop to iterate over multiple table columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-equivalent-of-FOR-loop-to-iterate-over-multiple-table/m-p/2746439#M84600</link>
      <description>&lt;P&gt;Thank you &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="349489" data-lia-user-login="daXtreme" class="lia-mention lia-mention-user"&gt;daXtreme&lt;/a&gt;&amp;nbsp;for the advice. I have updated my question with additional detail and a new subject.&lt;/P&gt;</description>
      <pubDate>Sun, 04 Sep 2022 22:42:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Need-equivalent-of-FOR-loop-to-iterate-over-multiple-table/m-p/2746439#M84600</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-09-04T22:42:59Z</dc:date>
    </item>
  </channel>
</rss>

