<?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 Text value from a column to filter another table in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Text-value-from-a-column-to-filter-another-table/m-p/1134039#M16886</link>
    <description>&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;I can't figure out how to retrieve the text value (the &lt;EM&gt;metal&lt;/EM&gt; field in the example below) from a column to be used as a filter for another column, row by row, so to fill a visual table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this two tables:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MetalValues&lt;/STRONG&gt;, with the market value of different metals (here just two as an example) along the year:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Metal&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Value&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2020&lt;/TD&gt;&lt;TD&gt;Iron&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/1/2020&lt;/TD&gt;&lt;TD&gt;Iron&lt;/TD&gt;&lt;TD&gt;199&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2020&lt;/TD&gt;&lt;TD&gt;Copper&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/1/2020&lt;/TD&gt;&lt;TD&gt;Copper&lt;/TD&gt;&lt;TD&gt;51&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Production&lt;/STRONG&gt;, with the metals production of the day for the full year:&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Metal&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ProducedQuantity&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2020&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Iron&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2020&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Copper&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/1/2020&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Iron&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/1/2020&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Copper&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two tables are linked with an inactive relation between the Date columns, so that I can make use of USERELATIONSHIP to temporarily activate the relation and filter by date (it would create issues if I leave the relation active).&lt;/P&gt;&lt;P&gt;But I can't figure out how to also filter by metal so to have the correct multiplication.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to have a &lt;FONT color="#333399"&gt;&lt;U&gt;visual&lt;/U&gt;&amp;nbsp;&lt;/FONT&gt;table that shows Production and its values, like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;&lt;STRONG&gt;Production[Date]&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;&lt;STRONG&gt;Production[Metal]&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;&lt;STRONG&gt;TotalValue&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;1/1/2020&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;Iron&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;2000&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;2/1/2020&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;Iron&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;2388&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;...&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given that I need to relate both by &lt;EM&gt;date&lt;/EM&gt; and by &lt;EM&gt;metal&lt;/EM&gt;, I assumed this could have worked:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TotalValue= 
  CALCULATE(
    MAX(MetalValues[Value])*MAX(Production[ProducedQuantity]),
    FILTER(MetalValues, MetalValues[Metal]=Production[Metal]),
    USERELATIONSHIP(Production[Date],MetalValues[Date])
  )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code above, USERELATIONSHIP actually retrieves the right dates from MetalValues, but I get an error on the FILTER that aims to also retrieve the right metal, because I'm providing a column (Production[Metal]) instead than a single value.&lt;/P&gt;&lt;P&gt;How shall I code this second filter on the metal value?&lt;/P&gt;</description>
    <pubDate>Mon, 01 Jun 2020 19:48:04 GMT</pubDate>
    <dc:creator>OnlyPhilip</dc:creator>
    <dc:date>2020-06-01T19:48:04Z</dc:date>
    <item>
      <title>Text value from a column to filter another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Text-value-from-a-column-to-filter-another-table/m-p/1134039#M16886</link>
      <description>&lt;P&gt;Hi everybody,&lt;/P&gt;&lt;P&gt;I can't figure out how to retrieve the text value (the &lt;EM&gt;metal&lt;/EM&gt; field in the example below) from a column to be used as a filter for another column, row by row, so to fill a visual table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have this two tables:&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;MetalValues&lt;/STRONG&gt;, with the market value of different metals (here just two as an example) along the year:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Metal&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Value&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2020&lt;/TD&gt;&lt;TD&gt;Iron&lt;/TD&gt;&lt;TD&gt;200&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/1/2020&lt;/TD&gt;&lt;TD&gt;Iron&lt;/TD&gt;&lt;TD&gt;199&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2020&lt;/TD&gt;&lt;TD&gt;Copper&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/1/2020&lt;/TD&gt;&lt;TD&gt;Copper&lt;/TD&gt;&lt;TD&gt;51&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Production&lt;/STRONG&gt;, with the metals production of the day for the full year:&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;STRONG&gt;Date&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;Metal&lt;/STRONG&gt;&lt;/TD&gt;&lt;TD&gt;&lt;STRONG&gt;ProducedQuantity&lt;/STRONG&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2020&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Iron&lt;/TD&gt;&lt;TD&gt;10&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1/1/2020&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Copper&lt;/TD&gt;&lt;TD&gt;50&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/1/2020&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Iron&lt;/TD&gt;&lt;TD&gt;12&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2/1/2020&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Copper&lt;/TD&gt;&lt;TD&gt;60&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The two tables are linked with an inactive relation between the Date columns, so that I can make use of USERELATIONSHIP to temporarily activate the relation and filter by date (it would create issues if I leave the relation active).&lt;/P&gt;&lt;P&gt;But I can't figure out how to also filter by metal so to have the correct multiplication.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I would like to have a &lt;FONT color="#333399"&gt;&lt;U&gt;visual&lt;/U&gt;&amp;nbsp;&lt;/FONT&gt;table that shows Production and its values, like this:&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;&lt;STRONG&gt;Production[Date]&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;&lt;STRONG&gt;Production[Metal]&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;&lt;STRONG&gt;TotalValue&lt;/STRONG&gt;&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;1/1/2020&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;Iron&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;2000&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;2/1/2020&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;Iron&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;2388&lt;/FONT&gt;&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;&lt;FONT color="#333399"&gt;...&lt;/FONT&gt;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Given that I need to relate both by &lt;EM&gt;date&lt;/EM&gt; and by &lt;EM&gt;metal&lt;/EM&gt;, I assumed this could have worked:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;TotalValue= 
  CALCULATE(
    MAX(MetalValues[Value])*MAX(Production[ProducedQuantity]),
    FILTER(MetalValues, MetalValues[Metal]=Production[Metal]),
    USERELATIONSHIP(Production[Date],MetalValues[Date])
  )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the code above, USERELATIONSHIP actually retrieves the right dates from MetalValues, but I get an error on the FILTER that aims to also retrieve the right metal, because I'm providing a column (Production[Metal]) instead than a single value.&lt;/P&gt;&lt;P&gt;How shall I code this second filter on the metal value?&lt;/P&gt;</description>
      <pubDate>Mon, 01 Jun 2020 19:48:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Text-value-from-a-column-to-filter-another-table/m-p/1134039#M16886</guid>
      <dc:creator>OnlyPhilip</dc:creator>
      <dc:date>2020-06-01T19:48:04Z</dc:date>
    </item>
    <item>
      <title>Re: Text value from a column to filter another table</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Text-value-from-a-column-to-filter-another-table/m-p/1134467#M16898</link>
      <description>&lt;P&gt;You can not need the inactive relationship at all if your use an approach using TREATAS() as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Total Value =&lt;BR /&gt;VAR __qty =&lt;BR /&gt;SUM ( Production[Produced Quantity] )&lt;BR /&gt;VAR __metalvalue =&lt;BR /&gt;CALCULATE (&lt;BR /&gt;MIN ( MetalValues[Value] ),&lt;BR /&gt;TREATAS ( VALUES ( Production[Date] ), MetalValues[Date] ),&lt;BR /&gt;TREATAS ( VALUES ( Production[Metal] ), MetalValues[Metal] )&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;__qty * __metalvalue&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Or you could use USERELATIONSHIP for the date and just use TREATAS() on metal column.&amp;nbsp; Note: this assumes you are using the columns from Production in your visuals (for Metal and Date).&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If this works for you, please mark it as solution.&amp;nbsp; Kudos are appreciated too.&amp;nbsp; Please let me know if not.&lt;/P&gt;&lt;P&gt;Regards,&lt;/P&gt;&lt;P&gt;Pat&lt;/P&gt;</description>
      <pubDate>Tue, 02 Jun 2020 01:51:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Text-value-from-a-column-to-filter-another-table/m-p/1134467#M16898</guid>
      <dc:creator>mahoneypat</dc:creator>
      <dc:date>2020-06-02T01:51:45Z</dc:date>
    </item>
  </channel>
</rss>

