<?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: DAX: Adding a new column from an existing formula in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Adding-a-new-column-from-an-existing-formula/m-p/3556454#M136907</link>
    <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the following error message:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The measures well don't work if they have 'Orders'. For example,&amp;nbsp;&lt;SPAN&gt;Orders[OrderHot] needs to be [OrderHot] but I'm not too sure.&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 28 Nov 2023 12:44:18 GMT</pubDate>
    <dc:creator>LABrowne</dc:creator>
    <dc:date>2023-11-28T12:44:18Z</dc:date>
    <item>
      <title>DAX: Adding a new column from an existing formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Adding-a-new-column-from-an-existing-formula/m-p/3556438#M136902</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am building a live dashboard with an order table.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The below represents what I use to colour cells/row of the order table based on a certain set of conditions.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Background Cancellation Colours =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;CancelledOrders&lt;/SPAN&gt;&lt;SPAN&gt;&amp;nbsp;= &lt;/SPAN&gt;&lt;SPAN&gt;CONTAINSSTRING&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt; (Orders[OrderNumber&lt;/SPAN&gt;&lt;SPAN&gt;]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;"Cancelled"&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;UnderReviewOrders&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;= &lt;/SPAN&gt;&lt;SPAN&gt;CONTAINSSTRING&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;MAX&lt;/SPAN&gt;&lt;SPAN&gt; (Orders[OrderNumber]&lt;/SPAN&gt;&lt;SPAN&gt;), &lt;/SPAN&gt;&lt;SPAN&gt;"Under Review"&lt;/SPAN&gt;&lt;SPAN&gt;) &amp;amp;&amp;amp; &lt;/SPAN&gt;&lt;SPAN&gt;TODAY&lt;/SPAN&gt;&lt;SPAN&gt;() &amp;lt;= &lt;/SPAN&gt;&lt;SPAN&gt;[Expiry Date Less 90 Days]&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;VAR&lt;/SPAN&gt; &lt;SPAN&gt;HotOrders&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;[OrderHot]&lt;/SPAN&gt;&lt;SPAN&gt; &amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;100&lt;/SPAN&gt;&lt;SPAN&gt; &amp;amp;&amp;amp; &lt;/SPAN&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IV&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;I want to add a new column on the policy table actually puts each order into a category so it can be counted, analysed etc.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Below is a simple idea of what I want it to look like&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;OrderNumber&lt;/TD&gt;&lt;TD&gt;*NEED NEW COLUMN FORMULA?*&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;123 - Cancelled&lt;/TD&gt;&lt;TD&gt;Cancelled&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;12334 - Under Review&lt;/TD&gt;&lt;TD&gt;Under Review&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2134&lt;/TD&gt;&lt;TD&gt;N/A&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hot would be for all orders &amp;gt; 100 &amp;amp; N/A would be for everything else that doesn't meet any 3 criteria.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Please let me know if you need any other advice&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 28 Nov 2023 12:22:04 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Adding-a-new-column-from-an-existing-formula/m-p/3556438#M136902</guid>
      <dc:creator>LABrowne</dc:creator>
      <dc:date>2023-11-28T12:22:04Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Adding a new column from an existing formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Adding-a-new-column-from-an-existing-formula/m-p/3556448#M136906</link>
      <description>&lt;P&gt;Plz try this DAX:&lt;/P&gt;&lt;P&gt;\NewCategoryColumn =&lt;BR /&gt;ADDCOLUMNS (&lt;BR /&gt;Orders,&lt;BR /&gt;"Category",&lt;BR /&gt;SWITCH (&lt;BR /&gt;TRUE(),&lt;BR /&gt;CONTAINSSTRING( Orders[OrderNumber], "Cancelled"), "Cancelled",&lt;BR /&gt;CONTAINSSTRING( Orders[OrderNumber], "Under Review") &amp;amp;&amp;amp; TODAY() &amp;lt;= Orders[Expiry Date Less 90 Days], "Under Review",&lt;BR /&gt;Orders[OrderHot] &amp;gt; 100 &amp;amp;&amp;amp; Orders[No. of Issues] &amp;gt;= 2 &amp;amp;&amp;amp; TODAY() &amp;lt;= Orders[Expiry Date Less 90 Days], "Hot",&lt;BR /&gt;"N/A"&lt;BR /&gt;)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This code adds a new column called "Category" to the Orders table. The SWITCH function is used to evaluate each order based on the specified conditions, and the corresponding category is assigned to the "Category" column.&lt;/P&gt;&lt;P&gt;You can adjust the conditions in the SWITCH statement based on your specific criteria. The last condition in the SWITCH statement, "N/A", will be applied if none of the previous conditions are met.&lt;/P&gt;&lt;P&gt;Make sure to replace the column names (Orders[OrderNumber], Orders[Expiry Date Less 90 Days], Orders[OrderHot], Orders[No. of Issues]) with your actual column names.&lt;/P&gt;&lt;P&gt;After creating this new column, you can use it in your dashboard for analysis and visualization.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 12:30:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Adding-a-new-column-from-an-existing-formula/m-p/3556448#M136906</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-11-28T12:30:12Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Adding a new column from an existing formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Adding-a-new-column-from-an-existing-formula/m-p/3556454#M136907</link>
      <description>&lt;P&gt;Hi there,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I got the following error message:&amp;nbsp;&lt;/P&gt;&lt;PRE&gt;The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The measures well don't work if they have 'Orders'. For example,&amp;nbsp;&lt;SPAN&gt;Orders[OrderHot] needs to be [OrderHot] but I'm not too sure.&lt;/SPAN&gt;&amp;nbsp;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 12:44:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Adding-a-new-column-from-an-existing-formula/m-p/3556454#M136907</guid>
      <dc:creator>LABrowne</dc:creator>
      <dc:date>2023-11-28T12:44:18Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Adding a new column from an existing formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Adding-a-new-column-from-an-existing-formula/m-p/3556500#M136912</link>
      <description>&lt;P&gt;&lt;SPAN&gt;You're right; when creating a calculated column in Power BI, you need to reference columns without specifying the table name. Here's the corrected formula:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Category =&lt;BR /&gt;VAR CancelledOrders = CONTAINSSTRING( Orders[OrderNumber], "Cancelled")&lt;BR /&gt;VAR UnderReviewOrders = CONTAINSSTRING( Orders[OrderNumber], "Under Review") &amp;amp;&amp;amp; TODAY() &amp;lt;= Orders[Expiry Date Less 90 Days]&lt;BR /&gt;VAR HotOrders = Orders[OrderHot] &amp;gt; 100 &amp;amp;&amp;amp; Orders[No. of Issues] &amp;gt;= 2 &amp;amp;&amp;amp; TODAY() &amp;lt;= Orders[Expiry Date Less 90 Days]&lt;BR /&gt;RETURN&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;CancelledOrders, "Cancelled",&lt;BR /&gt;UnderReviewOrders, "Under Review",&lt;BR /&gt;HotOrders, "Hot",&lt;BR /&gt;"N/A"&lt;BR /&gt;)&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In this corrected formula, I removed the table prefix (Orders) from the column references, assuming that you are adding this calculated column to the Orders table. Make sure you add this formula to the "Orders" table.&lt;/P&gt;&lt;P&gt;If you're still encountering issues, please double-check the column names in your actual data model and replace them accordingly. If you provide more details about your data model or any specific error messages, I'll be happy to assist further.&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 13:10:51 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Adding-a-new-column-from-an-existing-formula/m-p/3556500#M136912</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-11-28T13:10:51Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Adding a new column from an existing formula</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Adding-a-new-column-from-an-existing-formula/m-p/3556567#M136924</link>
      <description>&lt;P&gt;Perfect thanks! By any chance do you know how I would filter the results of the filter? e.g. is there a way to be able to filter the visual table based on measure results/values?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Kind regards,&lt;/P&gt;&lt;P&gt;Luke&lt;/P&gt;</description>
      <pubDate>Tue, 28 Nov 2023 13:48:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Adding-a-new-column-from-an-existing-formula/m-p/3556567#M136924</guid>
      <dc:creator>LABrowne</dc:creator>
      <dc:date>2023-11-28T13:48:38Z</dc:date>
    </item>
  </channel>
</rss>

