<?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: Categorise values in a measure not a column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Categorise-values-in-a-measure-not-a-column/m-p/3005241#M101660</link>
    <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="480439" data-lia-user-login="JamesMF1982" class="lia-mention lia-mention-user"&gt;JamesMF1982&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, you want to convert the calculated column to the measure , you can try to use this dax:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;EnquiryDaysToConvert = 
if(ENQUIRYDETAILS[EnquiryCurrentStageID] = 3,
SWITCH(
True(),
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)&amp;lt;=10,"0 - 10 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)&amp;lt;=15,"11 - 15 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)&amp;lt;=20,"0 - 20 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)&amp;lt;=25,"21 - 25 days",
if(DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)&amp;lt;=30,"26 - 30 days",
"Over 30 days"),blank())
&lt;/LI-CODE&gt;
&lt;P&gt;Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Aniya Zhang&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; it as the solution&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly&lt;/P&gt;</description>
    <pubDate>Fri, 06 Jan 2023 08:50:03 GMT</pubDate>
    <dc:creator>v-yueyunzh-msft</dc:creator>
    <dc:date>2023-01-06T08:50:03Z</dc:date>
    <item>
      <title>Categorise values in a measure not a column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Categorise-values-in-a-measure-not-a-column/m-p/2964851#M98893</link>
      <description>&lt;P&gt;Hi,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to be able to categorise dates into a number of categories and then put them into a pie chart, now I know the best way is to put them into a column, however I am pulling a dataset that isn't able to modified by myself and would be chargeable by our third party and so a measure would be free.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I worked what the column calculation would be:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EnquiryDaysToConvert = if(ENQUIRYDETAILS[EnquiryCurrentStageID] = 3,&lt;BR /&gt;if(DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)&amp;lt;=10,"0 - 10 days",&lt;BR /&gt;if(DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)&amp;lt;=15,"11 - 15 days",&lt;BR /&gt;if(DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)&amp;lt;=20,"0 - 20 days",&lt;BR /&gt;if(DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)&amp;lt;=25,"21 - 25 days",&lt;BR /&gt;if(DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)&amp;lt;=30,"26 - 30 days","Over 30 days"))))),"")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;However, I am not sure if this can be transferred to a measure. Any help would be amazing thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;James&lt;/P&gt;</description>
      <pubDate>Tue, 13 Dec 2022 09:56:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Categorise-values-in-a-measure-not-a-column/m-p/2964851#M98893</guid>
      <dc:creator>JamesMF1982</dc:creator>
      <dc:date>2022-12-13T09:56:06Z</dc:date>
    </item>
    <item>
      <title>Re: Categorise values in a measure not a column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Categorise-values-in-a-measure-not-a-column/m-p/2965403#M98940</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="480439" data-lia-user-login="JamesMF1982" class="lia-mention lia-mention-user"&gt;JamesMF1982&lt;/a&gt;&amp;nbsp;,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;There exists a "switch" statement in DAX -&amp;nbsp;&lt;A href="https://dax.guide/switch/" target="_blank"&gt;https://dax.guide/switch/.&lt;/A&gt;&lt;/P&gt;&lt;P&gt;For example this measure works for me:&lt;/P&gt;&lt;DIV&gt;&lt;PRE&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;EM&gt;Measure = IF(SELECTEDVALUE(Sheet1[yearmonth]) &amp;lt;= 202210, &amp;nbsp;&lt;BR /&gt;switch(TRUE,&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;EM&gt;   AND (sum(Sheet1[cal1])&amp;gt;10, sum(Sheet1[cal1])&amp;lt;=20),"&amp;gt;10 &amp;lt;=20",&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;EM&gt;   sum(Sheet1[cal1])&amp;gt;40,"&amp;gt;40",&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;EM&gt;    sum(Sheet1[cal1])&amp;gt;30,"&amp;gt;30")&lt;BR /&gt;)&lt;/EM&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;DIV&gt;&lt;FONT size="4"&gt;For your requirement , this would look something like:&lt;/FONT&gt;&lt;/DIV&gt;&lt;PRE&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;EM&gt;&lt;SPAN&gt;EnquiryDaysToConvert = if(ENQUIRYDETAILS[EnquiryCurrentStageID] = 3,&lt;/SPAN&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;EM&gt;SWITCH(&lt;/EM&gt;&lt;/FONT&gt;&lt;BR /&gt;&lt;FONT size="1 2 3 4 5 6 7"&gt;&lt;EM&gt;&lt;SPAN&gt;DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)&amp;lt;=10,"0 - 10 days",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)&amp;lt;=15,"11 - 15 days",&lt;/SPAN&gt;&lt;BR /&gt;&lt;SPAN&gt;DATEDIFF(ENQUIRYDETAILS[EnquiryBecameLeadDate],ENQUIRYDETAILS[EnquiryBecameClient],DAY)&amp;lt;=20,"0 - 20 days",.......))&lt;/SPAN&gt;&lt;BR /&gt;&lt;/EM&gt;&lt;/FONT&gt;&lt;/PRE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="4"&gt;&lt;EM&gt;HTH&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;FONT size="4"&gt;&lt;EM&gt;Pi&lt;/EM&gt;&lt;/FONT&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Tue, 13 Dec 2022 13:26:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Categorise-values-in-a-measure-not-a-column/m-p/2965403#M98940</guid>
      <dc:creator>pi_eye</dc:creator>
      <dc:date>2022-12-13T13:26:29Z</dc:date>
    </item>
    <item>
      <title>Re: Categorise values in a measure not a column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Categorise-values-in-a-measure-not-a-column/m-p/3005241#M101660</link>
      <description>&lt;P&gt;Hi ,&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="480439" data-lia-user-login="JamesMF1982" class="lia-mention lia-mention-user"&gt;JamesMF1982&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;According to your description, you want to convert the calculated column to the measure , you can try to use this dax:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;EnquiryDaysToConvert = 
if(ENQUIRYDETAILS[EnquiryCurrentStageID] = 3,
SWITCH(
True(),
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)&amp;lt;=10,"0 - 10 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)&amp;lt;=15,"11 - 15 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)&amp;lt;=20,"0 - 20 days",
DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)&amp;lt;=25,"21 - 25 days",
if(DATEDIFF(max(ENQUIRYDETAILS[EnquiryBecameLeadDate]),max(ENQUIRYDETAILS[EnquiryBecameClient]),DAY)&amp;lt;=30,"26 - 30 days",
"Over 30 days"),blank())
&lt;/LI-CODE&gt;
&lt;P&gt;Thank you for your time and sharing, and thank you for your support and understanding of PowerBI!&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Aniya Zhang&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;helps&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept&lt;/EM&gt;&lt;/STRONG&gt;&lt;EM&gt; it as the solution&lt;/EM&gt;&amp;nbsp;to help the other members find it more quickly&lt;/P&gt;</description>
      <pubDate>Fri, 06 Jan 2023 08:50:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Categorise-values-in-a-measure-not-a-column/m-p/3005241#M101660</guid>
      <dc:creator>v-yueyunzh-msft</dc:creator>
      <dc:date>2023-01-06T08:50:03Z</dc:date>
    </item>
  </channel>
</rss>

