<?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: Addcolumn with if statement in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/2675667#M79936</link>
    <description>&lt;P&gt;Thanks for replying&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="377293" data-lia-user-login="SpartaBI" class="lia-mention lia-mention-user"&gt;SpartaBI&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to add a new column to the BookingStatus table using DAX, which uses the IF statement.&lt;/P&gt;</description>
    <pubDate>Tue, 02 Aug 2022 13:13:56 GMT</pubDate>
    <dc:creator>C4L84</dc:creator>
    <dc:date>2022-08-02T13:13:56Z</dc:date>
    <item>
      <title>Addcolumn with if statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/2675064#M79890</link>
      <description>&lt;P&gt;Hi community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm looking for some help with an ADDCOLUMN expression.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to add a new column called "RevenueType" in the BookingStatus table which groups BookingCodes A, R, H and CX as "Confirmed revenue" with all remaining codes as "Provisional".&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is a pbix &lt;A href="https://www.dropbox.com/s/1bgqgovycyby6nn/Example%201.pbix?dl=0" target="_self"&gt;example&lt;/A&gt;.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've got as far as creating the if statement:&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RevenueType = &lt;/SPAN&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Booking statuses'[BookingCode]&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;SPAN&gt;"A"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"R"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"H"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"CX"&lt;/SPAN&gt;&lt;SPAN&gt;}, &lt;/SPAN&gt;&lt;SPAN&gt;"Confirmed revenue"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Provisional"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But can't figure out how to add this column to the table as I am getting and error that reads "The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value."&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It should be noted that this has to be a DAX expression and the data cannot be modified in the query editor.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I'm hoping someone in the community can help as I've been stuck on this for some time!&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 Aug 2022 09:17:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/2675064#M79890</guid>
      <dc:creator>C4L84</dc:creator>
      <dc:date>2022-08-02T09:17:50Z</dc:date>
    </item>
    <item>
      <title>Re: Addcolumn with if statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/2675535#M79920</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="156886" data-lia-user-login="C4L84" class="lia-mention lia-mention-user"&gt;C4L84&lt;/a&gt;&amp;nbsp;do you mean like this?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RevenueType = IF('Booking statuses'[BookingCode] in {"A","R","H","CX"}, "Confirmed revenue", "Provisional")&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Here is a link to download the file with the solution:&lt;BR /&gt;&lt;A href="https://spartabiltd-my.sharepoint.com/:u:/g/personal/avishayf_spartabi_com/ETsqw5xU1pBGtpXrm1CEhrMB2IvKoQGnwkoj7LVSXt3J7g?e=P7vUMg" target="_blank"&gt;Addcolumn with if statement 2022-08-02.pbix&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;&lt;A href="https://www.spartabi.com" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://www.spartabi.com" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&lt;A href="https://www.linkedin.com/company/spartabi" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt; &amp;nbsp;&amp;nbsp;&lt;A href="https://www.facebook.com/SpartaBI" target="_blank" rel="noopener"&gt;&lt;img /&gt;&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;A href="https://community.powerbi.com/t5/Data-Stories-Gallery/Contoso-by-SpartaBI/m-p/2449543" target="_blank" rel="noopener"&gt;&lt;FONT size="4" color="#0000EE"&gt;Showcase Report – Contoso By SpartaBI&lt;/FONT&gt;&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 12:21:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/2675535#M79920</guid>
      <dc:creator>SpartaBI</dc:creator>
      <dc:date>2022-08-02T12:21:51Z</dc:date>
    </item>
    <item>
      <title>Re: Addcolumn with if statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/2675667#M79936</link>
      <description>&lt;P&gt;Thanks for replying&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="377293" data-lia-user-login="SpartaBI" class="lia-mention lia-mention-user"&gt;SpartaBI&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need to add a new column to the BookingStatus table using DAX, which uses the IF statement.&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:13:56 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/2675667#M79936</guid>
      <dc:creator>C4L84</dc:creator>
      <dc:date>2022-08-02T13:13:56Z</dc:date>
    </item>
    <item>
      <title>Re: Addcolumn with if statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/2675695#M79939</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="156886" data-lia-user-login="C4L84" class="lia-mention lia-mention-user"&gt;C4L84&lt;/a&gt;&amp;nbsp;i'm confused &lt;span class="lia-unicode-emoji" title=":beaming_face_with_smiling_eyes:"&gt;😁&lt;/span&gt; isn't it what I sent you?&lt;/P&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:26:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/2675695#M79939</guid>
      <dc:creator>SpartaBI</dc:creator>
      <dc:date>2022-08-02T13:26:02Z</dc:date>
    </item>
    <item>
      <title>Re: Addcolumn with if statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/2675698#M79940</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="377293" data-lia-user-login="SpartaBI" class="lia-mention lia-mention-user"&gt;SpartaBI&lt;/a&gt;&amp;nbsp;I need to specifically use the ADDCOLUMN funtion, something like this:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RevenueType = &lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;ADDCOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Booking statuses'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"RevenueType"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;&lt;BR /&gt;&lt;DIV&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;MIN&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Booking statuses'[BookingCode]&lt;/SPAN&gt;&lt;SPAN&gt;) &lt;/SPAN&gt;&lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;SPAN&gt;"A"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"R"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"H"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"CX"&lt;/SPAN&gt;&lt;SPAN&gt;}, &lt;/SPAN&gt;&lt;SPAN&gt;"Confirmed revenue"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Provisional"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;But I am getting this error message:&amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 02 Aug 2022 13:28:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/2675698#M79940</guid>
      <dc:creator>C4L84</dc:creator>
      <dc:date>2022-08-02T13:28:32Z</dc:date>
    </item>
    <item>
      <title>Re: Addcolumn with if statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/3311286#M123801</link>
      <description>&lt;P&gt;Hi, I know it has been a while since you posted your question. Did you come across with any solution? I am having the same issue.&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2023 03:50:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/3311286#M123801</guid>
      <dc:creator>Ivn_rmr</dc:creator>
      <dc:date>2023-07-02T03:50:25Z</dc:date>
    </item>
    <item>
      <title>Re: Addcolumn with if statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/3311417#M123805</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="583444" data-lia-user-login="Ivn_rmr" class="lia-mention lia-mention-user"&gt;Ivn_rmr&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Please explain your issue perhaps I can help.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;With regard to this particular question, I can see that&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="377293" data-lia-user-login="SpartaBI" class="lia-mention lia-mention-user"&gt;SpartaBI&lt;/a&gt;&amp;nbsp;already provided a workable solution. However, the request of using ADDCOLUMNS function as per&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="156886" data-lia-user-login="C4L84" class="lia-mention lia-mention-user"&gt;C4L84&lt;/a&gt;&amp;nbsp;is not clear as ADDCOLUMNS returns a table not a scalar value.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sun, 02 Jul 2023 09:33:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/3311417#M123805</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-07-02T09:33:21Z</dc:date>
    </item>
    <item>
      <title>Re: Addcolumn with if statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/3325986#M124544</link>
      <description>&lt;P&gt;I am not sure that you need to use the addcolumn function for this but if you really need to let me know.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I achieved what you are looking for by adding a new column as shown below:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Then I inputted the following in the formula bar:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RevenueType = IF('Booking statuses'[BookingCode] in {"A","R","H","CX"},"Confirmed Revenue", "Provisional")&lt;/LI-CODE&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;RevenueType = &lt;/SPAN&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Booking statuses'&lt;/SPAN&gt;&lt;SPAN&gt;[BookingCode]&lt;/SPAN&gt; &lt;SPAN&gt;in&lt;/SPAN&gt;&lt;SPAN&gt; {&lt;/SPAN&gt;&lt;SPAN&gt;"A"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"R"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"H"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"CX"&lt;/SPAN&gt;&lt;SPAN&gt;},&lt;/SPAN&gt;&lt;SPAN&gt;"Confirmed Revenue"&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;"Provisional"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;See result below:&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 11 Jul 2023 20:15:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/3325986#M124544</guid>
      <dc:creator>Vasuno1</dc:creator>
      <dc:date>2023-07-11T20:15:27Z</dc:date>
    </item>
    <item>
      <title>Re: Addcolumn with if statement</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/3327448#M124621</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="156886" data-lia-user-login="C4L84" class="lia-mention lia-mention-user"&gt;C4L84&lt;/a&gt;&amp;nbsp; - Sorry I didn't realize that you reiterated your absolute need to use the ADDCOLUMNS function (nor did I notice that someone already posted the exact solution I did&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":disappointed_face:"&gt;😞&lt;/span&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="156886" data-lia-user-login="C4L84" class="lia-mention lia-mention-user"&gt;C4L84&lt;/a&gt;&amp;nbsp; / &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="583444" data-lia-user-login="Ivn_rmr" class="lia-mention lia-mention-user"&gt;Ivn_rmr&lt;/a&gt;&amp;nbsp; - I used the below formula to create the table using the ADDCOLUMNS function:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;RevenueType = ADDCOLUMNS('Booking statuses',"RevenueType",IF('Booking statuses'[BookingCode] in {"A","R","H","CX"},"Confirmed Revenue", "Provisional"))&lt;/LI-CODE&gt;</description>
      <pubDate>Wed, 12 Jul 2023 13:25:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Addcolumn-with-if-statement/m-p/3327448#M124621</guid>
      <dc:creator>Vasuno1</dc:creator>
      <dc:date>2023-07-12T13:25:00Z</dc:date>
    </item>
  </channel>
</rss>

