<?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 Using MonthName function in a set expression is not working as expected in QlikView</title>
    <link>https://community.qlik.com/t5/QlikView/Using-MonthName-function-in-a-set-expression-is-not-working-as/m-p/1530310#M746470</link>
    <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;I have to get average of records for last 3 months. I was using below logic to get it but am not getting correct result.&lt;/P&gt;&lt;P&gt;=Avg({&amp;lt;MonthYear ={$(=MonthName(Addmonths(today(),-1))),$(=MonthName(Addmonths(today(),-2))),$(=MonthName(Addmonths(today(),-3)))}&amp;gt;}Field)&lt;/P&gt;&lt;P&gt;where the expression&amp;nbsp;&lt;SPAN&gt;=MonthName(Addmonths(today(),-1)) will give you Dec 2018 and MonthYear field is MonthName(Date)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think it's because of the $ expansion there might be something going wrong but i am not sure.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Although when I use the following expression, i get the correct result.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;=Avg({&amp;lt;MonthYear = {"=MonthYear =MonthName(Addmonths(today(),-1))","=MonthYear =MonthName(Addmonths(today(),-2))","=MonthYear =MonthName(Addmonths(today(),-3))"}&amp;gt;}Field)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I know i could have just used the second expression but I am curious why the first one did not work or is there any better solution to this problem than second expression.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any input would be appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Pranav&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Sat, 16 Nov 2024 21:36:08 GMT</pubDate>
    <dc:creator>pranaview</dc:creator>
    <dc:date>2024-11-16T21:36:08Z</dc:date>
    <item>
      <title>Using MonthName function in a set expression is not working as expected</title>
      <link>https://community.qlik.com/t5/QlikView/Using-MonthName-function-in-a-set-expression-is-not-working-as/m-p/1530310#M746470</link>
      <description>&lt;P&gt;Hi Guys,&lt;/P&gt;&lt;P&gt;I have to get average of records for last 3 months. I was using below logic to get it but am not getting correct result.&lt;/P&gt;&lt;P&gt;=Avg({&amp;lt;MonthYear ={$(=MonthName(Addmonths(today(),-1))),$(=MonthName(Addmonths(today(),-2))),$(=MonthName(Addmonths(today(),-3)))}&amp;gt;}Field)&lt;/P&gt;&lt;P&gt;where the expression&amp;nbsp;&lt;SPAN&gt;=MonthName(Addmonths(today(),-1)) will give you Dec 2018 and MonthYear field is MonthName(Date)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I think it's because of the $ expansion there might be something going wrong but i am not sure.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Although when I use the following expression, i get the correct result.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;=Avg({&amp;lt;MonthYear = {"=MonthYear =MonthName(Addmonths(today(),-1))","=MonthYear =MonthName(Addmonths(today(),-2))","=MonthYear =MonthName(Addmonths(today(),-3))"}&amp;gt;}Field)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I know i could have just used the second expression but I am curious why the first one did not work or is there any better solution to this problem than second expression.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Any input would be appreciated.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Cheers,&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Pranav&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 16 Nov 2024 21:36:08 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-MonthName-function-in-a-set-expression-is-not-working-as/m-p/1530310#M746470</guid>
      <dc:creator>pranaview</dc:creator>
      <dc:date>2024-11-16T21:36:08Z</dc:date>
    </item>
    <item>
      <title>Re: Using MonthName function in a set expression is not working as expected</title>
      <link>https://community.qlik.com/t5/QlikView/Using-MonthName-function-in-a-set-expression-is-not-working-as/m-p/1530341#M746471</link>
      <description>&lt;P&gt;You will need quotes as well.&lt;/P&gt;&lt;PRE&gt;=Avg({&amp;lt;MonthYear ={"$(=MonthName(Addmonths(today(),-1)))",&lt;BR /&gt;"$(=MonthName(Addmonths(today(),-2)))",&lt;BR /&gt;"$(=MonthName(Addmonths(today(),-3)))"}&amp;gt;} Field)&lt;/PRE&gt;</description>
      <pubDate>Tue, 15 Jan 2019 10:01:30 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-MonthName-function-in-a-set-expression-is-not-working-as/m-p/1530341#M746471</guid>
      <dc:creator>jonathandienst</dc:creator>
      <dc:date>2019-01-15T10:01:30Z</dc:date>
    </item>
    <item>
      <title>Re: Using MonthName function in a set expression is not working as expected</title>
      <link>https://community.qlik.com/t5/QlikView/Using-MonthName-function-in-a-set-expression-is-not-working-as/m-p/1530352#M746472</link>
      <description>Hi Jonty,&lt;BR /&gt;&lt;BR /&gt;Thanks for the tip. Worked like a charm. Classic case of "Why didn't I think of that".&lt;BR /&gt;&lt;BR /&gt;Regards,&lt;BR /&gt;Pranav</description>
      <pubDate>Tue, 15 Jan 2019 10:17:37 GMT</pubDate>
      <guid>https://community.qlik.com/t5/QlikView/Using-MonthName-function-in-a-set-expression-is-not-working-as/m-p/1530352#M746472</guid>
      <dc:creator>pranaview</dc:creator>
      <dc:date>2019-01-15T10:17:37Z</dc:date>
    </item>
  </channel>
</rss>

