<?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: Distinct Count by filter in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2350285#M59627</link>
    <description>&lt;P&gt;Thank you, It's nice, but i think it can be resolve with measure&lt;/P&gt;</description>
    <pubDate>Mon, 21 Feb 2022 07:28:12 GMT</pubDate>
    <dc:creator>vaalyushin</dc:creator>
    <dc:date>2022-02-21T07:28:12Z</dc:date>
    <item>
      <title>Distinct Count by filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347601#M59413</link>
      <description>&lt;P&gt;Good afternoon!&lt;BR /&gt;&lt;BR /&gt;I need to get the number of open and closed applications. At the same time, the application may have a history of its states (open, in operation, closed, resolved)&lt;BR /&gt;&lt;BR /&gt;My dataset:&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ticket_number&lt;/TD&gt;&lt;TD&gt;current_status&lt;/TD&gt;&lt;TD&gt;created_date&lt;/TD&gt;&lt;TD&gt;status_date_change&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;open&lt;/TD&gt;&lt;TD&gt;1.01.2022&lt;/TD&gt;&lt;TD&gt;1.01.2022&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;in progress&lt;/TD&gt;&lt;TD&gt;2.01.2022&lt;/TD&gt;&lt;TD&gt;2.01.2022&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;open&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;in progress&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;closed&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;open&lt;/TD&gt;&lt;TD&gt;3.02.2023&lt;/TD&gt;&lt;TD&gt;3.02.2023&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;</description>
      <pubDate>Fri, 18 Feb 2022 11:39:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347601#M59413</guid>
      <dc:creator>vaalyushin</dc:creator>
      <dc:date>2022-02-18T11:39:07Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count by filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347702#M59416</link>
      <description>&lt;P&gt;Could you create a flag in your dataset to identify the latest status for each ticket based on created_date and a sort of the current_status, then filter for this in your report or within a measure?&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;ticket_number&lt;/TD&gt;&lt;TD&gt;current_status&lt;/TD&gt;&lt;TD&gt;created_date&lt;/TD&gt;&lt;TD&gt;status_date_change&lt;/TD&gt;&lt;TD&gt;latest_status_flag&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;open&lt;/TD&gt;&lt;TD&gt;1.01.2022&lt;/TD&gt;&lt;TD&gt;1.01.2022&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;in progress&lt;/TD&gt;&lt;TD&gt;2.01.2022&lt;/TD&gt;&lt;TD&gt;2.01.2022&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;open&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;in progress&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;TD&gt;0&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;closed&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;TD&gt;2.02.2022&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;TD&gt;open&lt;/TD&gt;&lt;TD&gt;3.02.2023&lt;/TD&gt;&lt;TD&gt;3.02.2023&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;PRE&gt;CALCULATE(COUNTROWS(YourDataset),&amp;nbsp;latest_status_flag = 1)&lt;/PRE&gt;&lt;P&gt;Might be easier than trying to serve it all up in a measure.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT: COUNTROWS.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 12:40:21 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347702#M59416</guid>
      <dc:creator>Russell-PBI</dc:creator>
      <dc:date>2022-02-18T12:40:21Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count by filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347704#M59418</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="330707" data-lia-user-login="vaalyushin" class="lia-mention lia-mention-user"&gt;vaalyushin&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;You have only options for the satus which are: &lt;STRONG&gt;Open&lt;/STRONG&gt;, then it will become &lt;STRONG&gt;In Progress&lt;/STRONG&gt;&amp;nbsp;(In Operation) then it will be either &lt;STRONG&gt;Closed&lt;/STRONG&gt; or &lt;STRONG&gt;Resolved&lt;/STRONG&gt;. Am I right? Do you have other options?&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 12:38:45 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347704#M59418</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-02-18T12:38:45Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count by filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347705#M59419</link>
      <description>&lt;P&gt;Yes, you are right&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 12:40:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347705#M59419</guid>
      <dc:creator>vaalyushin</dc:creator>
      <dc:date>2022-02-18T12:40:07Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count by filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347729#M59420</link>
      <description>&lt;P&gt;I didn't fully understand what you meant.&amp;nbsp;now I do it through the measure, but naturally I get the wrong result&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;CountOpenTickets = 
CALCULATE (
    DISTINCTCOUNT('tickets'[issue_number] ),
    FILTER (
        'tickets',
        'tickets'[current_status] = "Open"
            &amp;amp;&amp;amp; 'tickets'[creation_date] = MAX ('jira_vulnerability_issues'[creation_date])
    )
)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 12:55:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347729#M59420</guid>
      <dc:creator>vaalyushin</dc:creator>
      <dc:date>2022-02-18T12:55:43Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count by filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347756#M59425</link>
      <description>&lt;P&gt;This probably isn't the most streamlined solution as I don't use PowerQuery for transformations, but here is what I came up with:&amp;nbsp;&lt;A href="https://drive.google.com/file/d/16XYzwjHyqbhbhbSodc03yXOPorGpj_V3/view?usp=sharing" target="_blank" rel="noopener"&gt;https://drive.google.com/file/d/16XYzwjHyqbhbhbSodc03yXOPorGpj_V3/view?usp=sharing&lt;/A&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Effectively, it works out the latest created_date per ticket, the latest current_status based on what will most likely come after each status, then uses the combination of those two bits of information to decide which record is the latest per ticket. If that doesn't work because status will change back and forth, then you might need to consider adding date and time into your dataset rather than just date.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 13:08:48 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347756#M59425</guid>
      <dc:creator>Russell-PBI</dc:creator>
      <dc:date>2022-02-18T13:08:48Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count by filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347765#M59427</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="330707" data-lia-user-login="vaalyushin" class="lia-mention lia-mention-user"&gt;vaalyushin&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;Here is the sample file with the solution&amp;nbsp;&lt;A href="https://www.dropbox.com/t/fZytnjZorSijq226" target="_blank"&gt;https://www.dropbox.com/t/fZytnjZorSijq226&lt;/A&gt;&lt;BR /&gt;A new calculated column has to be created:&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Status = 
VAR CurrentTicket = Tickets[ticket_number]
VAR CurrentTicketAllAvailableStatuses =
    FILTER (
        Tickets,
        Tickets[ticket_number] = CurrentTicket
    )
VAR Result =
    SWITCH (
        TRUE,
        CONTAINS ( CurrentTicketAllAvailableStatuses, Tickets[current_status], "Resolved" ), "Resolved",
        CONTAINS ( CurrentTicketAllAvailableStatuses, Tickets[current_status], "Closed" ), "Closed",
        CONTAINS ( CurrentTicketAllAvailableStatuses, Tickets[current_status], "Resolved" ), "Resolved",
        CONTAINS ( CurrentTicketAllAvailableStatuses, Tickets[current_status], "In Progress" ), "In Progress",
        "Open"
    )
RETURN
    Result &lt;/LI-CODE&gt;&lt;P&gt;The measure is a simple distinct count&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;Ticket Count = 
    COUNTROWS ( DISTINCT ( Tickets[ticket_number] ) )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;You can use the newly caculated column in rows or slicers. And the measure will give you the distinct count as per your selection.&lt;/P&gt;</description>
      <pubDate>Fri, 18 Feb 2022 13:15:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2347765#M59427</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2022-02-18T13:15:12Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count by filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2350285#M59627</link>
      <description>&lt;P&gt;Thank you, It's nice, but i think it can be resolve with measure&lt;/P&gt;</description>
      <pubDate>Mon, 21 Feb 2022 07:28:12 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2350285#M59627</guid>
      <dc:creator>vaalyushin</dc:creator>
      <dc:date>2022-02-21T07:28:12Z</dc:date>
    </item>
    <item>
      <title>Re: Distinct Count by filter</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2351113#M59680</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="317289" data-lia-user-login="tamerj1" class="lia-mention lia-mention-user"&gt;tamerj1&lt;/a&gt;'s posted solution works with a calculated column and measure, so no messing about with PowerQuery. I'd say that's a good solution for you.&lt;/P&gt;</description>
      <pubDate>Mon, 21 Feb 2022 12:33:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Distinct-Count-by-filter/m-p/2351113#M59680</guid>
      <dc:creator>Russell-PBI</dc:creator>
      <dc:date>2022-02-21T12:33:49Z</dc:date>
    </item>
  </channel>
</rss>

