<?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: Using variable result in another Variable? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-variable-result-in-another-Variable/m-p/4160292#M165308</link>
    <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="232360" data-lia-user-login="ptmuldoon" class="lia-mention lia-mention-user"&gt;ptmuldoon&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try the below code..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Occupied Rooms =&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;VAR ItemValue = &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;SWITCH (&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;VALUES ('Measures List'[Fact Period]),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"Day", [QTY], &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"Last 7", [Last 7 QTY], &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"MTD", [MTD QTY], &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"QTD", [QTD QTY], &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"YTD", [YTD QTY])&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;VAR MyItem = &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;CALCULATE(ItemValue, 'Dim Item'[description] = "OCCUPIED ROOMS")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;RETURN &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;SWITCH (&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;VALUES ('FactType'[FactType]),"#", MyItem,"% of Avail. Rooms", DIVIDE( MyItem, CALCULATE([QTY], 'Dim Item'[description] = "AVAILABLE ROOMS") ))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes are much appreciated!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;&lt;P&gt;Dharmendar S&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.linkedin.com/in/dharmendar-s-b5b43463/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;LinkedIN&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 19 Sep 2024 16:40:23 GMT</pubDate>
    <dc:creator>dharmendars007</dc:creator>
    <dc:date>2024-09-19T16:40:23Z</dc:date>
    <item>
      <title>Using variable result in another Variable?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-variable-result-in-another-Variable/m-p/4160017#M165300</link>
      <description>&lt;P&gt;I am trying to use the result of 1 variable into a 2nd variable in computing a value.&amp;nbsp; &amp;nbsp;I know I can do this with nested Switch Statements, but trying to see if this methos would work as well.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In the below, I am trying to replace [QTY] value in the Var MyItem and in the Return dependent upon what is selected from the Var ItemValue.&amp;nbsp; &amp;nbsp;Yet, it returns an incorrect value when I try it.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anyone maybe help troubleshoot the below?&amp;nbsp; Is it even possible?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you,&lt;/P&gt;&lt;P&gt;Paul&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;Occupied Rooms = 
    VAR ItemValue =
    SWITCH (
		VALUES ('Measures List'[Fact Period]),
        "Day", [QTY],
		"Last 7", [Last 7 QTY],
		"MTD", [MTD QTY],
		"QTD", [QTD QTY],
		"YTD", [YTD QTY]
	)

    Var Myitem = CALCULATE([QTY],'Dim Item'[description]="OCCUPIED ROOMS")
    RETURN
        SWITCH (
            VALUES ('FactType'[FactType]),
                "#", Myitem,
                "% of Avail. Rooms", DIVIDE( Myitem, CALCULATE([QTY],'Dim Item'[description]="AVAILABLE ROOMS") )
	)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 14:29:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-variable-result-in-another-Variable/m-p/4160017#M165300</guid>
      <dc:creator>ptmuldoon</dc:creator>
      <dc:date>2024-09-19T14:29:05Z</dc:date>
    </item>
    <item>
      <title>Re: Using variable result in another Variable?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-variable-result-in-another-Variable/m-p/4160198#M165305</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="232360" data-lia-user-login="ptmuldoon" class="lia-mention lia-mention-user"&gt;ptmuldoon&lt;/a&gt;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Field parameters offer a robust way to capture the selected measure. You could create a field parameter using the five measures in variable ItemValue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;A href="https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters" target="_self"&gt;https://learn.microsoft.com/en-us/power-bi/create-reports/power-bi-field-parameters&lt;/A&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 15:45:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-variable-result-in-another-Variable/m-p/4160198#M165305</guid>
      <dc:creator>DataInsights</dc:creator>
      <dc:date>2024-09-19T15:45:45Z</dc:date>
    </item>
    <item>
      <title>Re: Using variable result in another Variable?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-variable-result-in-another-Variable/m-p/4160292#M165308</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="232360" data-lia-user-login="ptmuldoon" class="lia-mention lia-mention-user"&gt;ptmuldoon&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You can try the below code..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;Occupied Rooms =&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;VAR ItemValue = &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;SWITCH (&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;VALUES ('Measures List'[Fact Period]),&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"Day", [QTY], &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"Last 7", [Last 7 QTY], &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"MTD", [MTD QTY], &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"QTD", [QTD QTY], &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;"YTD", [YTD QTY])&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;VAR MyItem = &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;CALCULATE(ItemValue, 'Dim Item'[description] = "OCCUPIED ROOMS")&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&lt;FONT color="#FF0000"&gt;RETURN &lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;SWITCH (&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT color="#FF0000"&gt;VALUES ('FactType'[FactType]),"#", MyItem,"% of Avail. Rooms", DIVIDE( MyItem, CALCULATE([QTY], 'Dim Item'[description] = "AVAILABLE ROOMS") ))&lt;/FONT&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes are much appreciated!&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank You&lt;/P&gt;&lt;P&gt;Dharmendar S&lt;/P&gt;&lt;P&gt;&lt;A href="https://www.linkedin.com/in/dharmendar-s-b5b43463/" target="_blank" rel="noopener"&gt;&lt;SPAN&gt;LinkedIN&lt;/SPAN&gt;&lt;/A&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 16:40:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-variable-result-in-another-Variable/m-p/4160292#M165308</guid>
      <dc:creator>dharmendars007</dc:creator>
      <dc:date>2024-09-19T16:40:23Z</dc:date>
    </item>
    <item>
      <title>Re: Using variable result in another Variable?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-variable-result-in-another-Variable/m-p/4160453#M165311</link>
      <description>&lt;P&gt;I'm definitely struggling with this today, and I think the issue may have something to do with the ability to pass a variable meaure into the Calculate function?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried with the field paramater, and also tried&amp;nbsp;@&lt;SPAN&gt;dharmendars007 code, and get the same incorrect value.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I place the Switch statement directly within the Calculate function, it works as expected.&amp;nbsp; But if change out the Switch statement with variable name in the Calculate, it returns an incorrect value?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can you use a variable measure in Calculate?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT.&amp;nbsp; &amp;nbsp;Pretty sure you can't use the Variable in the Calculate, and finally found an explanation here that makes sense.&amp;nbsp; The Variable gets totaled before the filtering in the Calculate, thus the wrong response is given.&lt;/P&gt;&lt;P&gt;&lt;A href="https://radacad.com/caution-when-using-variables-in-dax-and-power-bi" target="_blank"&gt;https://radacad.com/caution-when-using-variables-in-dax-and-power-bi&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&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;Occupied Rooms = 

    VAR _Period =  SWITCH (
		    VALUES ('Measures List'[Fact Period]),
            "Day", [QTY],
	    	"Last 7", [Last 7 QTY],
		    "MTD", [MTD QTY],
		    "QTD", [QTD QTY],
		    "YTD", [YTD QTY]
	        )

    RETURN

    CALCULATE(
        SWITCH (
		    VALUES ('Measures List'[Fact Period]),
            "Day", [QTY],
	    	"Last 7", [Last 7 QTY],
		    "MTD", [MTD QTY],
		    "QTD", [QTD QTY],
		    "YTD", [YTD QTY]
	        )
        ,'Dim Item'[description]="OCCUPIED ROOMS"
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 19 Sep 2024 19:50:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Using-variable-result-in-another-Variable/m-p/4160453#M165311</guid>
      <dc:creator>ptmuldoon</dc:creator>
      <dc:date>2024-09-19T19:50:26Z</dc:date>
    </item>
  </channel>
</rss>

