<?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: Countrows if ID is unique in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4036146#M159955</link>
    <description>&lt;P&gt;Thank you so much&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="490030" data-lia-user-login="Irwan" class="lia-mention lia-mention-user"&gt;Irwan&lt;/a&gt;&amp;nbsp; That totally solved my problem.&lt;/P&gt;&lt;P&gt;I am so happy now, i really tried so many things, nothing worked the way i wanted.&lt;/P&gt;&lt;P&gt;You solved it, thank you. Never thought it was under measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You know why it show 14 as total?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 11 Jul 2024 05:22:55 GMT</pubDate>
    <dc:creator>Peter_K</dc:creator>
    <dc:date>2024-07-11T05:22:55Z</dc:date>
    <item>
      <title>Countrows if ID is unique</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4034733#M159855</link>
      <description>&lt;P&gt;Hello. I have browsed your solutions here, but coudn't find anything i could use in my situation.&lt;/P&gt;&lt;P&gt;I am all new to PowerBI.&lt;/P&gt;&lt;P&gt;I have a JSON datasource, with&amp;nbsp;500 chats in it.&amp;nbsp;It has following columns:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;started&lt;/TD&gt;&lt;TD&gt;initialUserMessage&lt;/TD&gt;&lt;TD&gt;messageCount&lt;/TD&gt;&lt;TD&gt;chatId&lt;/TD&gt;&lt;TD&gt;startUrl&lt;/TD&gt;&lt;TD&gt;logEvents&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here i have a example from the content, so i better can explain my wish:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Every chat has a unique chatId. So initialUserMessage appear on multiple rows with that unique chatId. 1 row for each text sent from and to the user.&lt;/P&gt;&lt;P&gt;What i like to achieve is a table where it counts initialUserMessage only one time, for each unique chatId. ie:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Hey&lt;/TD&gt;&lt;TD&gt;25&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Printer is offline&lt;/TD&gt;&lt;TD&gt;8&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;My word tells me its invalid code&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What i have tried so far, either leave me with error, 1, 500, or even:&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Hey&lt;/TD&gt;&lt;TD&gt;574725&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;Printer is offline&lt;/TD&gt;&lt;TD&gt;367824&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I dont seem to get it right.&lt;/P&gt;&lt;P&gt;The formula i tried and messed around with, is like this now, and gives value 500 (the total chats)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;test1 = CALCULATE(DISTINCTCOUNT(chat_logs[chatId]),FILTER(chat_logs, chat_logs[initialUserMessage]=chat_logs[initialUserMessage]))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Here is the structure of JSON import, where test1 is the one i try this in:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Can you please help me with this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you in advance.&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 13:24:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4034733#M159855</guid>
      <dc:creator>Peter_K</dc:creator>
      <dc:date>2024-07-10T13:24:17Z</dc:date>
    </item>
    <item>
      <title>Re: Countrows if ID is unique</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4034848#M159870</link>
      <description>&lt;P&gt;I can't clean the JSON file for GDPR content.&lt;BR /&gt;The file has confidental data.&lt;BR /&gt;Does that mean you cant help me?&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 14:07:15 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4034848#M159870</guid>
      <dc:creator>Peter_K</dc:creator>
      <dc:date>2024-07-10T14:07:15Z</dc:date>
    </item>
    <item>
      <title>Re: Countrows if ID is unique</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4035689#M159925</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="773247" data-lia-user-login="Peter_K" class="lia-mention lia-mention-user"&gt;Peter_K&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;please check if this accomodate your need.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I made a random data based on your problem.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Create a measure with following DAX:&lt;/P&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Count =&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;var&lt;/SPAN&gt; &lt;SPAN&gt;_Message&lt;/SPAN&gt;&lt;SPAN&gt; = &lt;/SPAN&gt;&lt;SPAN&gt;SELECTEDVALUE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Message]&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Return&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;CALCULATE&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;DISTINCTCOUNT&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[ChatID]&lt;/SPAN&gt;&lt;SPAN&gt;),&lt;/SPAN&gt;&lt;SPAN&gt;FILTER&lt;/SPAN&gt;&lt;SPAN&gt;(&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;,&lt;/SPAN&gt;&lt;SPAN&gt;'Table'&lt;/SPAN&gt;&lt;SPAN&gt;[Message]&lt;/SPAN&gt;&lt;SPAN&gt;=&lt;/SPAN&gt;&lt;SPAN&gt;_Message&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;If this result doesnt match to your problem, please give a set of dummy data that can represent your whole data.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Hope this will help you.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;DIV&gt;&lt;SPAN&gt;Thank you.&lt;/SPAN&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 10 Jul 2024 23:20:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4035689#M159925</guid>
      <dc:creator>Irwan</dc:creator>
      <dc:date>2024-07-10T23:20:48Z</dc:date>
    </item>
    <item>
      <title>Re: Countrows if ID is unique</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4036146#M159955</link>
      <description>&lt;P&gt;Thank you so much&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="490030" data-lia-user-login="Irwan" class="lia-mention lia-mention-user"&gt;Irwan&lt;/a&gt;&amp;nbsp; That totally solved my problem.&lt;/P&gt;&lt;P&gt;I am so happy now, i really tried so many things, nothing worked the way i wanted.&lt;/P&gt;&lt;P&gt;You solved it, thank you. Never thought it was under measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;You know why it show 14 as total?&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 05:22:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4036146#M159955</guid>
      <dc:creator>Peter_K</dc:creator>
      <dc:date>2024-07-11T05:22:55Z</dc:date>
    </item>
    <item>
      <title>Re: Countrows if ID is unique</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4036164#M159956</link>
      <description>&lt;P&gt;hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="773247" data-lia-user-login="Peter_K" class="lia-mention lia-mention-user"&gt;Peter_K&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;glad to be a help.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 05:25:29 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4036164#M159956</guid>
      <dc:creator>Irwan</dc:creator>
      <dc:date>2024-07-11T05:25:29Z</dc:date>
    </item>
    <item>
      <title>Re: Countrows if ID is unique</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4036685#M160000</link>
      <description>&lt;P&gt;Hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="773247" data-lia-user-login="Peter_K" class="lia-mention lia-mention-user"&gt;Peter_K&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;that happens because of the filter in calculate DAX. The total seems not be able to be calculated properly.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In my sample data, the total didnt even show up.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;To solve this, simply just remove the filter and use DISTINCTCOUNT directly&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact, if your data has uniqueID for every message, I think direct distinctcount should do the job (no need put any filter by calculate DAX).&lt;/P&gt;&lt;P&gt;But please give it a try first and let see if you get the correct value or not by using direct distinctcount.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Hope this will help you.&lt;/P&gt;&lt;P&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Thu, 11 Jul 2024 08:52:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4036685#M160000</guid>
      <dc:creator>Irwan</dc:creator>
      <dc:date>2024-07-11T08:52:55Z</dc:date>
    </item>
    <item>
      <title>Re: Countrows if ID is unique</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4041622#M160254</link>
      <description>&lt;P&gt;Thank you very much.&lt;/P&gt;&lt;P&gt;This solved it.&lt;/P&gt;&lt;P&gt;I know there is exact 500 chats, and thats also the result.&lt;/P&gt;&lt;P&gt;You solved my problem, thanks.&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2024 05:21:22 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4041622#M160254</guid>
      <dc:creator>Peter_K</dc:creator>
      <dc:date>2024-07-15T05:21:22Z</dc:date>
    </item>
    <item>
      <title>Re: Countrows if ID is unique</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4041634#M160257</link>
      <description>&lt;P&gt;hello&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="773247" data-lia-user-login="Peter_K" class="lia-mention lia-mention-user"&gt;Peter_K&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;glad to be a help.&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;Thank you.&lt;/P&gt;</description>
      <pubDate>Mon, 15 Jul 2024 05:31:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Countrows-if-ID-is-unique/m-p/4041634#M160257</guid>
      <dc:creator>Irwan</dc:creator>
      <dc:date>2024-07-15T05:31:20Z</dc:date>
    </item>
  </channel>
</rss>

