<?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: Measure with a variable in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-a-variable/m-p/985017#M12108</link>
    <description>Here's the full and correct solution:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://1drv.ms/u/s!ApyQEauTSLtOgYM665_GXHuUZylVyw?e=IQUTF8" target="_blank"&gt;https://1drv.ms/u/s!ApyQEauTSLtOgYM665_GXHuUZylVyw?e=IQUTF8&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
    <pubDate>Sat, 21 Mar 2020 10:58:40 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-03-21T10:58:40Z</dc:date>
    <item>
      <title>Measure with a variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-a-variable/m-p/984231#M12058</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to upgrade a company report such that it is future proof. I am currently facing a seemingly simple problem which has been bugging me for the past 2 days. I can't share the data but I'll try to sketch the scenario as well as possible.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My data consists of many rows and columns, which are divided according to the following example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;table 1&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;&amp;nbsp;&lt;/TD&gt;&lt;TD&gt;Class&lt;/TD&gt;&lt;TD&gt;Value&lt;/TD&gt;&lt;TD&gt;Slicer columns&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;Fullfills requirements&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;Fullfills requirements&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;A&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;Bad solution&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;4&lt;/TD&gt;&lt;TD&gt;Fullfills requirements&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;B&lt;/TD&gt;&lt;TD&gt;5&lt;/TD&gt;&lt;TD&gt;Bad solution&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;6&lt;/TD&gt;&lt;TD&gt;Fullfills requirements&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;C&lt;/TD&gt;&lt;TD&gt;7&lt;/TD&gt;&lt;TD&gt;Bad solution&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Users give input in the various columns, which results in a solution meeting the requirements or not (here sumarized in a column, in the real report, this is done through slicers in the project). I want to find the maximum of the valid solutions per class, but at the same time I want to find the minimum of all the maximums (which is my most conservative solution to the problem). e.g. The maximum acceptable values are (2, 4 and 6), so my measure should output 2, which is the minimum of the 3 maximums.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My measure which does this, is as follows (I left the good/bad solution filter out for simplicity):&lt;BR /&gt;&lt;BR /&gt;measure =&lt;/P&gt;&lt;P&gt;VAR maxA = CALCULATE(MAX(table1[Value]); table1[Class] = "A")&lt;/P&gt;&lt;P&gt;VAR maxB = CALCULATE(MAX(table1[Value]); table1[Class] = "B")&lt;/P&gt;&lt;P&gt;VAR maxC = CALCULATE(MAX(table1[Value]); table1[Class] = "C")&lt;/P&gt;&lt;P&gt;RETURN MIN(MIN(maxA;maxB) ; maxC)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This measure does exactly as expected. However, the amount of classes in my data can change in the future. Hence, I would like to include a loop over a variable amount of classes instead of hard coding them.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The slicer criteria are set inside the report. Therefore, I cannot use the query editor, as that does all the calculations while loading the data, therefore ignoring future slicers (at least to my understanding, correct me if I am wrong). I think I am limited to using a measure, but those don't work well with variables/functions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope someone can help me out.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Cheers,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Jeffrey&lt;/P&gt;</description>
      <pubDate>Fri, 20 Mar 2020 15:11:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-a-variable/m-p/984231#M12058</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-20T15:11:23Z</dc:date>
    </item>
    <item>
      <title>Re: Measure with a variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-a-variable/m-p/984288#M12059</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;it looks like you need MINX() function like&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Measure = 
CALCULATE(
MINX('Table',
CALCULATE(MAX('Table'[Value]),ALLEXCEPT('Table','Table'[Class]))),
ALL('Table')
)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 20 Mar 2020 15:40:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-a-variable/m-p/984288#M12059</guid>
      <dc:creator>az38</dc:creator>
      <dc:date>2020-03-20T15:40:41Z</dc:date>
    </item>
    <item>
      <title>Re: Measure with a variable</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-a-variable/m-p/985017#M12108</link>
      <description>Here's the full and correct solution:&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://1drv.ms/u/s!ApyQEauTSLtOgYM665_GXHuUZylVyw?e=IQUTF8" target="_blank"&gt;https://1drv.ms/u/s!ApyQEauTSLtOgYM665_GXHuUZylVyw?e=IQUTF8&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;Best&lt;BR /&gt;D</description>
      <pubDate>Sat, 21 Mar 2020 10:58:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Measure-with-a-variable/m-p/985017#M12108</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-03-21T10:58:40Z</dc:date>
    </item>
  </channel>
</rss>

