<?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 Optimizing DAX for Supplier Data: Handling Missing Values in Calculated Columns in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Optimizing-DAX-for-Supplier-Data-Handling-Missing-Values-in/m-p/4147584#M164815</link>
    <description>&lt;P&gt;&lt;STRONG&gt;Question:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;In the calculated column below, we are determining the Last Year Unit price for suppliers. However, new suppliers lack data, resulting in blank rows. I need to amend the logic in the column to populate these blank values with those from existing suppliers for the same material number. Our data contains pairs of suppliers, and we want to use the value from the supplier that has the data.&lt;/P&gt;&lt;P&gt;I have managed to create a ‘test’ secondary calculated column that provides the results (shown below). I need to figure out a way to do this all in one column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help or suggestions would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Main Calculated Column:&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;LYUnitPriceUSD_DEC =&lt;BR /&gt;VAR __LastYearKey =&amp;nbsp;Table1[Column1] &amp;amp; "_" &amp;amp; Table1[Year]-1 &amp;amp; "_Q" &amp;amp; Table1[Quarter]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __ExcelValue = LOOKUPVALUE(&lt;BR /&gt;&amp;nbsp; Table2[PriceLastYear],&lt;BR /&gt;&amp;nbsp; Table2[Key],&lt;BR /&gt;&amp;nbsp; __LastYearKey)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __SAPValue =&lt;BR /&gt;&amp;nbsp; LOOKUPVALUE(&lt;BR /&gt;&amp;nbsp; Table3[AveragePrice],&lt;BR /&gt;&amp;nbsp; Table3[Key],&lt;BR /&gt;&amp;nbsp; Table1[Column1] &amp;amp; "_" &amp;amp; Table1[Year]-1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __CurrentRateYearCode =&lt;BR /&gt;&amp;nbsp; LEFT( RELATED(Table4[CurrencyYear]) , 3 )&lt;BR /&gt;&amp;nbsp; &amp;amp; "_" &amp;amp;&lt;BR /&gt;&amp;nbsp; IF(&lt;BR /&gt;&amp;nbsp; Table1[Year] &amp;gt; YEAR( TODAY() ),&lt;BR /&gt;&amp;nbsp; YEAR( TODAY() ),&lt;BR /&gt;&amp;nbsp; Table1[Year])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __RateMultiplication =&lt;BR /&gt;&amp;nbsp; LOOKUPVALUE(Table5[RateMultiplier],&lt;BR /&gt;&amp;nbsp; Table5[CurrencyYearKey],&lt;BR /&gt;&amp;nbsp; __CurrentRateYearCode)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __SAPValueCurrentRate = __SAPValue * __RateMultiplication&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __Result = COALESCE(__ExcelValue,__SAPValueCurrentRate)&lt;/P&gt;&lt;P&gt;RETURN __Result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;Test Column for Reference:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Find Duplicate Value test =&lt;BR /&gt;VAR __Exclude = CALCULATETABLE( VALUES(Table6[SupplierName]), Table6[Exclude] = "Exclude" )&lt;BR /&gt;VAR __AlternateLYValue =&amp;nbsp;&lt;BR /&gt;&amp;nbsp; IF(&amp;nbsp;NOT( ISBLANK(Table1[LYUnitPriceBudatUSD_DEC]) &amp;amp;&amp;amp; NOT( Table1[SupplierName] IN __Exclude ) ),&lt;BR /&gt;&amp;nbsp; Table1[LYUnitPriceBudatUSD_DEC],&lt;BR /&gt;CALCULATE(&lt;BR /&gt;&amp;nbsp; MAX( Table1[LYUnitPriceBudatUSD_DEC] ),&lt;BR /&gt;&amp;nbsp; FILTER(&amp;nbsp;Table1,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Table1[Year] = EARLIER( Table1[Year] )&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; Table1[ArticleNo] = EARLIER( Table1[ArticleNo] )&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; NOT( ISBLANK( Table1[LYUnitPriceBudatUSD_DEC]))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; NOT( Table1[SupplierName] IN __Exclude ) ) ) )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RETURN __AlternateLYValue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Disclosure:&lt;SPAN&gt;&amp;nbsp;This question was assisted by AI.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 12 Sep 2024 15:07:38 GMT</pubDate>
    <dc:creator>Martin-Edan</dc:creator>
    <dc:date>2024-09-12T15:07:38Z</dc:date>
    <item>
      <title>Optimizing DAX for Supplier Data: Handling Missing Values in Calculated Columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Optimizing-DAX-for-Supplier-Data-Handling-Missing-Values-in/m-p/4147584#M164815</link>
      <description>&lt;P&gt;&lt;STRONG&gt;Question:&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;In the calculated column below, we are determining the Last Year Unit price for suppliers. However, new suppliers lack data, resulting in blank rows. I need to amend the logic in the column to populate these blank values with those from existing suppliers for the same material number. Our data contains pairs of suppliers, and we want to use the value from the supplier that has the data.&lt;/P&gt;&lt;P&gt;I have managed to create a ‘test’ secondary calculated column that provides the results (shown below). I need to figure out a way to do this all in one column.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help or suggestions would be greatly appreciated!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Main Calculated Column:&lt;/STRONG&gt;&lt;/P&gt;&lt;DIV&gt;&lt;P&gt;LYUnitPriceUSD_DEC =&lt;BR /&gt;VAR __LastYearKey =&amp;nbsp;Table1[Column1] &amp;amp; "_" &amp;amp; Table1[Year]-1 &amp;amp; "_Q" &amp;amp; Table1[Quarter]&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __ExcelValue = LOOKUPVALUE(&lt;BR /&gt;&amp;nbsp; Table2[PriceLastYear],&lt;BR /&gt;&amp;nbsp; Table2[Key],&lt;BR /&gt;&amp;nbsp; __LastYearKey)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __SAPValue =&lt;BR /&gt;&amp;nbsp; LOOKUPVALUE(&lt;BR /&gt;&amp;nbsp; Table3[AveragePrice],&lt;BR /&gt;&amp;nbsp; Table3[Key],&lt;BR /&gt;&amp;nbsp; Table1[Column1] &amp;amp; "_" &amp;amp; Table1[Year]-1)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __CurrentRateYearCode =&lt;BR /&gt;&amp;nbsp; LEFT( RELATED(Table4[CurrencyYear]) , 3 )&lt;BR /&gt;&amp;nbsp; &amp;amp; "_" &amp;amp;&lt;BR /&gt;&amp;nbsp; IF(&lt;BR /&gt;&amp;nbsp; Table1[Year] &amp;gt; YEAR( TODAY() ),&lt;BR /&gt;&amp;nbsp; YEAR( TODAY() ),&lt;BR /&gt;&amp;nbsp; Table1[Year])&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __RateMultiplication =&lt;BR /&gt;&amp;nbsp; LOOKUPVALUE(Table5[RateMultiplier],&lt;BR /&gt;&amp;nbsp; Table5[CurrencyYearKey],&lt;BR /&gt;&amp;nbsp; __CurrentRateYearCode)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __SAPValueCurrentRate = __SAPValue * __RateMultiplication&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR __Result = COALESCE(__ExcelValue,__SAPValueCurrentRate)&lt;/P&gt;&lt;P&gt;RETURN __Result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/DIV&gt;&lt;P&gt;&lt;STRONG&gt;Test Column for Reference:&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;Find Duplicate Value test =&lt;BR /&gt;VAR __Exclude = CALCULATETABLE( VALUES(Table6[SupplierName]), Table6[Exclude] = "Exclude" )&lt;BR /&gt;VAR __AlternateLYValue =&amp;nbsp;&lt;BR /&gt;&amp;nbsp; IF(&amp;nbsp;NOT( ISBLANK(Table1[LYUnitPriceBudatUSD_DEC]) &amp;amp;&amp;amp; NOT( Table1[SupplierName] IN __Exclude ) ),&lt;BR /&gt;&amp;nbsp; Table1[LYUnitPriceBudatUSD_DEC],&lt;BR /&gt;CALCULATE(&lt;BR /&gt;&amp;nbsp; MAX( Table1[LYUnitPriceBudatUSD_DEC] ),&lt;BR /&gt;&amp;nbsp; FILTER(&amp;nbsp;Table1,&lt;BR /&gt;&amp;nbsp; &amp;nbsp; Table1[Year] = EARLIER( Table1[Year] )&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; Table1[ArticleNo] = EARLIER( Table1[ArticleNo] )&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; NOT( ISBLANK( Table1[LYUnitPriceBudatUSD_DEC]))&lt;BR /&gt;&amp;nbsp; &amp;nbsp; &amp;amp;&amp;amp; NOT( Table1[SupplierName] IN __Exclude ) ) ) )&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;RETURN __AlternateLYValue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Disclosure:&lt;SPAN&gt;&amp;nbsp;This question was assisted by AI.&lt;/SPAN&gt;&lt;/STRONG&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 15:07:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Optimizing-DAX-for-Supplier-Data-Handling-Missing-Values-in/m-p/4147584#M164815</guid>
      <dc:creator>Martin-Edan</dc:creator>
      <dc:date>2024-09-12T15:07:38Z</dc:date>
    </item>
    <item>
      <title>Re: Optimizing DAX for Supplier Data: Handling Missing Values in Calculated Columns</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Optimizing-DAX-for-Supplier-Data-Handling-Missing-Values-in/m-p/4148139#M164839</link>
      <description>&lt;P&gt;Read about COALESCE&lt;/P&gt;</description>
      <pubDate>Thu, 12 Sep 2024 23:25:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Optimizing-DAX-for-Supplier-Data-Handling-Missing-Values-in/m-p/4148139#M164839</guid>
      <dc:creator>lbendlin</dc:creator>
      <dc:date>2024-09-12T23:25:17Z</dc:date>
    </item>
  </channel>
</rss>

