<?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 DAX: Distinct count - only first consecutive string in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Distinct-count-only-first-consecutive-string/m-p/3544352#M136274</link>
    <description>&lt;P&gt;Hi there, I have an OrderTable,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With Orders[OrderId] and I have multiple orders uploaded, see below example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;123-456&lt;/P&gt;&lt;P&gt;123-456 - Cancelled&lt;/P&gt;&lt;P&gt;123-456 - STW&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now on the system this counts total orders as 3, which is correct there is 3 orders on the system.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to write a dax formula that ignore any characters (inc. space) and only count the first consecutive string? So that the above order count would be 1 if that makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be great!&lt;/P&gt;</description>
    <pubDate>Tue, 21 Nov 2023 10:06:32 GMT</pubDate>
    <dc:creator>LABrowne</dc:creator>
    <dc:date>2023-11-21T10:06:32Z</dc:date>
    <item>
      <title>DAX: Distinct count - only first consecutive string</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Distinct-count-only-first-consecutive-string/m-p/3544352#M136274</link>
      <description>&lt;P&gt;Hi there, I have an OrderTable,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With Orders[OrderId] and I have multiple orders uploaded, see below example:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;123-456&lt;/P&gt;&lt;P&gt;123-456 - Cancelled&lt;/P&gt;&lt;P&gt;123-456 - STW&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Now on the system this counts total orders as 3, which is correct there is 3 orders on the system.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Is there any way to write a dax formula that ignore any characters (inc. space) and only count the first consecutive string? So that the above order count would be 1 if that makes sense.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Any help would be great!&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 10:06:32 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Distinct-count-only-first-consecutive-string/m-p/3544352#M136274</guid>
      <dc:creator>LABrowne</dc:creator>
      <dc:date>2023-11-21T10:06:32Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Distinct count - only first consecutive string</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Distinct-count-only-first-consecutive-string/m-p/3544390#M136275</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;If your order id has a consistent amount of characters here is one way to do this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Measure&lt;/SPAN&gt; &lt;SPAN&gt;8&lt;/SPAN&gt;&lt;SPAN&gt; =&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;COUNTROWS&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;//count the amount of orders&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;SUMMARIZE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;//group the table by orderids&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ADDCOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table (12)'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;"A"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;LEFT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table (12)'&lt;/SPAN&gt;&lt;SPAN&gt;[Column1]&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;7&lt;/SPAN&gt;&lt;SPAN&gt;)),&lt;/SPAN&gt;&lt;SPAN&gt;[A]&lt;/SPAN&gt; &lt;SPAN&gt;//add a column with first 7 characters = actual order id&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;)) &lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;End result:&lt;BR /&gt;&lt;img /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
If your orderids have different lenghts ping me with "@" and I will revise the dax.&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;I hope this post helps to solve your issue and if it does consider accepting it as a solution and giving the post a thumbs up!&lt;BR /&gt;&lt;BR /&gt;My LinkedIn: &lt;A href="https://www.linkedin.com/in/n%C3%A4ttiahov-00001/" target="_blank" rel="noopener"&gt;https://www.linkedin.com/in/n%C3%A4ttiahov-00001/&lt;/A&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Tue, 21 Nov 2023 10:35:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Distinct-count-only-first-consecutive-string/m-p/3544390#M136275</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2023-11-21T10:35:38Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Distinct count - only first consecutive string</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Distinct-count-only-first-consecutive-string/m-p/3544396#M136276</link>
      <description>&lt;P&gt;very simple.&lt;/P&gt;&lt;P&gt;add below column in your table and use that column in your visual:&lt;/P&gt;&lt;P&gt;NewColumn = SUBSTITUTE(SUBSTITUTE(Orders[OrderID], " - cancelled", ""), " - STV", "")&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;this will replace the&amp;nbsp;ext "- cancelled" and "- STV" with an empty string, effectively removing these parts from the OrderId column. The result is stored in the new column called NewColumn&lt;/P&gt;&lt;P&gt;If this helped, Subscribe AnalyticPulse on YouTube for future updates:&lt;BR /&gt;&lt;A href="https://www.youtube.com/@AnalyticPulse" target="_blank"&gt;https://www.youtube.com/@AnalyticPulse&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://instagram.com/analytic_pulse" target="_blank"&gt;https://instagram.com/analytic_pulse&lt;/A&gt;&lt;BR /&gt;&lt;A href="https://analyticpulse.blogspot.com/" target="_blank"&gt;https://analyticpulse.blogspot.com/&lt;/A&gt;&lt;/P&gt;&lt;P&gt;subscribe to Youtube channel For fun facts:&lt;BR /&gt;&lt;A href="https://www.youtube.com/@CogniJourney" target="_blank"&gt;https://www.youtube.com/@CogniJourney&lt;/A&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 10:38:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Distinct-count-only-first-consecutive-string/m-p/3544396#M136276</guid>
      <dc:creator>AnalyticPulse</dc:creator>
      <dc:date>2023-11-21T10:38:41Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Distinct count - only first consecutive string</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Distinct-count-only-first-consecutive-string/m-p/3544499#M136283</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="343431" data-lia-user-login="ValtteriN" class="lia-mention lia-mention-user"&gt;ValtteriN&lt;/a&gt;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for your help but yes the orderids have different lengths.&lt;/P&gt;</description>
      <pubDate>Tue, 21 Nov 2023 11:09:50 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Distinct-count-only-first-consecutive-string/m-p/3544499#M136283</guid>
      <dc:creator>LABrowne</dc:creator>
      <dc:date>2023-11-21T11:09:50Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Distinct count - only first consecutive string</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Distinct-count-only-first-consecutive-string/m-p/3550198#M136562</link>
      <description>&lt;P&gt;Hi &lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="636377" data-lia-user-login="LABrowne" class="lia-mention lia-mention-user"&gt;LABrowne&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Then this gets a bit tricky. My first suggestion would be to use powerquery if possible. There you could just split via delimiter like this:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P&gt;And now calculate the ids from the new column.&lt;BR /&gt;&lt;BR /&gt;&lt;STRONG&gt;OR:&lt;/STRONG&gt;&lt;BR /&gt;&lt;BR /&gt;With dax you could try something like this:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;Measure&lt;/SPAN&gt; &lt;SPAN&gt;9&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;/DIV&gt;
&lt;BR /&gt;&lt;BR /&gt;
&lt;DIV&gt;&lt;SPAN&gt;COUNTROWS&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;//count the amount of orders&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;SUMMARIZE&lt;/SPAN&gt;&lt;SPAN&gt;( &lt;/SPAN&gt;&lt;SPAN&gt;//group the table by orderids&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;ADDCOLUMNS&lt;/SPAN&gt;&lt;SPAN&gt;('Table (12)',&lt;/SPAN&gt;&lt;SPAN&gt;"A"&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;IF&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;SEARCH&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;" "&lt;/SPAN&gt;&lt;SPAN&gt;, 'Table (12)'[Column1], &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;)&amp;gt; &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/SPAN&gt;&lt;SPAN&gt;LEFT&lt;/SPAN&gt;&lt;SPAN&gt;('Table (12)'[Column1], &lt;/SPAN&gt;&lt;SPAN&gt;SEARCH&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;" "&lt;/SPAN&gt;&lt;SPAN&gt;, 'Table (12)'[Column1], &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;, &lt;/SPAN&gt;&lt;SPAN&gt;0&lt;/SPAN&gt;&lt;SPAN&gt;) - &lt;/SPAN&gt;&lt;SPAN&gt;1&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;DIV&gt;&lt;SPAN&gt;&lt;SPAN&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 'Table (12)'[Column1])),[A]))&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;End result:&lt;BR /&gt;&lt;/SPAN&gt;&lt;/SPAN&gt;&lt;img /&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;SPAN&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/SPAN&gt;&lt;/DIV&gt;
&lt;/DIV&gt;</description>
      <pubDate>Fri, 24 Nov 2023 05:40:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Distinct-count-only-first-consecutive-string/m-p/3550198#M136562</guid>
      <dc:creator>ValtteriN</dc:creator>
      <dc:date>2023-11-24T05:40:07Z</dc:date>
    </item>
  </channel>
</rss>

