<?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: Count The Number of Times a Measure Returns a Specific Value in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/3435665#M130356</link>
    <description>&lt;P&gt;Good day&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you are doing well. I have a similar (simpiler?) issue but I cant figure out how to resolve.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on an OLAP cube so I cannot create any columns in the model, only measures.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to build&amp;nbsp; a measure that counts the number of times the Feed Flag = "High" and another one to show the number of times the Feed Flag = "Low" as per the below.&amp;nbsp; All of the highlighted columns in the visual below are measures I have created based on the "feed kg Act" column.&amp;nbsp; I have built a second flag using decimals to flag "high" and "Low", not sure if this is better to use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add cards and other visuals to summarize this table based on this information.&amp;nbsp;&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;&lt;/P&gt;&lt;P&gt;Warmest regards,&lt;/P&gt;&lt;P&gt;Katie&lt;/P&gt;</description>
    <pubDate>Mon, 18 Sep 2023 08:48:27 GMT</pubDate>
    <dc:creator>Katie-Farrand12</dc:creator>
    <dc:date>2023-09-18T08:48:27Z</dc:date>
    <item>
      <title>Count The Number of Times a Measure Returns a Specific Value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/2390210#M62127</link>
      <description>&lt;P&gt;Greetings Community!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I need assistance with a cumulative measure that sums the number of times a specific text value is returned from several other measures. This is what my Matrix looks like:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Column "Project Number" is the Project Number.&lt;/P&gt;&lt;P&gt;Columns Capital Above, Lapsed Ship Date, Missing Ship Date, NPV Below, NPV Over, and Volume Over are all measures that return "Ok" if that aspect of the project does not violate a preestablished threshold and "Review" if it does. For example: if a project has a positive capital investment amount, the measure returns "Review" and vice versa. If a project's ship date has passed, the&amp;nbsp;measure returns "Review" and vice versa. So on and so forth.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;As you can see, we have multiple projects that have violated multiple thresholds and the measures are flagging them for review. For example, Project 1069672 has been flagged for violating the capital amount, ship date has passed, and sales volume thresholds.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My question is, how can I create a measure to count the number of times the other measures produce a "Review" result. Put another way,&amp;nbsp;Project 1069672 has three things that need to be reviewed. The result I am looking for is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;TABLE border="1"&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Project Number&lt;/TD&gt;&lt;TD&gt;Flag Count&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1069672&lt;/TD&gt;&lt;TD&gt;3&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1070717&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;1072947&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;etc...&lt;/TD&gt;&lt;TD&gt;etc...&lt;/TD&gt;&lt;/TR&gt;&lt;/TBODY&gt;&lt;/TABLE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Sat, 12 Mar 2022 22:44:40 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/2390210#M62127</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-12T22:44:40Z</dc:date>
    </item>
    <item>
      <title>Re: Count The Number of Times a Measure Returns a Specific Value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/2390357#M62140</link>
      <description>&lt;P&gt;Hi there&amp;nbsp;Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Here is one way you could write this:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Flag count =
VAR MeasureValues = {
    [Capital Above],
    [Lapsed Ship Date],
    [Missing Ship Date],
    [NPV Below],
    [NPV Over],
    [Volume Over]
}
RETURN
    SUMX ( MeasureValues, INT ( [Value] = "Review" ) )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;This assembles the measure values into a single table, then the count of "Review" values is found by summing over this table.&lt;/P&gt;
&lt;P&gt;&lt;FONT face="courier new,courier"&gt;INT ( [Value] = "Review" )&lt;/FONT&gt; converts True to 1 and False to 0.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;You could also consider changing the original measures so that they return 0/1 values, with a format string like &lt;FONT face="courier new,courier"&gt;"Review";"ERROR";"Ok"&lt;/FONT&gt;&lt;/P&gt;
&lt;P&gt;This would allow you to sum [Value] within SUMX, but still have the measures appear the same in visuals.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2022 07:09:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/2390357#M62140</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2022-03-13T07:09:17Z</dc:date>
    </item>
    <item>
      <title>Re: Count The Number of Times a Measure Returns a Specific Value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/2390656#M62163</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This works perfectly, thank you as always!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Another question for you though, based on what you said about c&lt;SPAN&gt;hanging the original measures so that they return 0/1 values. This brings up another idea:&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Each project has a project owner, and a project owner might be responsible for several projects. Let's say Project Owner A is responsible for 8 different projects. Of those 8 projects, their total flag count is 12. How would you write that DAX formula so I could show that total number on a Card visual?&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2022 18:56:44 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/2390656#M62163</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-13T18:56:44Z</dc:date>
    </item>
    <item>
      <title>Re: Count The Number of Times a Measure Returns a Specific Value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/2390691#M62167</link>
      <description>&lt;P&gt;That's good, you're welcome &lt;span class="lia-unicode-emoji" title=":slightly_smiling_face:"&gt;🙂&lt;/span&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;In order to sum across projects, you essentially need to wrap the earlier measure in a SUMX. You could do this by modifying the original measure (you could also put it in a second measure referencing the first):&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Flag count =
SUMX (
    VALUES ( YourTable[Project Number] ),
    VAR MeasureValues = {
        [Capital Above],
        [Lapsed Ship Date],
        [Missing Ship Date],
        [NPV Below],
        [NPV Over],
        [Volume Over]
    }
    RETURN
        SUMX ( MeasureValues, INT ( [Value] = "Review" ) )
)&lt;/LI-CODE&gt;
&lt;P&gt;This measure should work either when grouping by individual projects or by Project Owners.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Does this work as expected?&lt;/P&gt;</description>
      <pubDate>Sun, 13 Mar 2022 20:45:36 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/2390691#M62167</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2022-03-13T20:45:36Z</dc:date>
    </item>
    <item>
      <title>Re: Count The Number of Times a Measure Returns a Specific Value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/2393598#M62353</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Excellent this works perfectly!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you for your assitance and taking the time to read through my post.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;-GC&lt;/P&gt;</description>
      <pubDate>Mon, 14 Mar 2022 22:09:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/2393598#M62353</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2022-03-14T22:09:25Z</dc:date>
    </item>
    <item>
      <title>Re: Count The Number of Times a Measure Returns a Specific Value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/3435665#M130356</link>
      <description>&lt;P&gt;Good day&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I hope you are doing well. I have a similar (simpiler?) issue but I cant figure out how to resolve.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am working on an OLAP cube so I cannot create any columns in the model, only measures.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I am trying to build&amp;nbsp; a measure that counts the number of times the Feed Flag = "High" and another one to show the number of times the Feed Flag = "Low" as per the below.&amp;nbsp; All of the highlighted columns in the visual below are measures I have created based on the "feed kg Act" column.&amp;nbsp; I have built a second flag using decimals to flag "high" and "Low", not sure if this is better to use?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to add cards and other visuals to summarize this table based on this information.&amp;nbsp;&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;&lt;/P&gt;&lt;P&gt;Warmest regards,&lt;/P&gt;&lt;P&gt;Katie&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 08:48:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/3435665#M130356</guid>
      <dc:creator>Katie-Farrand12</dc:creator>
      <dc:date>2023-09-18T08:48:27Z</dc:date>
    </item>
    <item>
      <title>Re: Count The Number of Times a Measure Returns a Specific Value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/3435993#M130374</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="337059" data-lia-user-login="Katie-Farrand12" class="lia-mention lia-mention-user"&gt;Katie-Farrand12&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I'm fine thanks, and I hope you're well too.&lt;/P&gt;
&lt;P&gt;You can use a pattern like this to count occurrences of a certain measure value:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Feed Flag High Count =
COUNTROWS (
    FILTER (
        SUMMARIZE (
            YourTable,
            -- The columns listed below are the columns to group by
            -- when evaluating the measure.
            YourTable[Unit],
            YourTable[Date]
        ),
        [Fee Flag] = "High"
    )
)&lt;/LI-CODE&gt;
&lt;P&gt;Notes:&lt;/P&gt;
&lt;UL&gt;
&lt;LI&gt;Within &lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;SUMMARIZE&lt;/FONT&gt;&lt;/STRONG&gt;, the first &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;YourTable&amp;nbsp;&lt;/STRONG&gt;&lt;/FONT&gt;should be replaced by the relevant fact table name (presumably the table containing Feed Kg Act values).&lt;/LI&gt;
&lt;LI&gt;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;YourTable[Unit]&lt;/STRONG&gt;&lt;/FONT&gt;and&amp;nbsp;&lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;YourTable[Date]&lt;/STRONG&gt;&lt;/FONT&gt;should be changed to correct column references.&lt;/LI&gt;
&lt;LI&gt;The group-by columns within SUMMARIZE in this example are &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;YourTable[Unit]&lt;/STRONG&gt;&lt;/FONT&gt; and &lt;FONT face="courier new,courier"&gt;&lt;STRONG&gt;YourTable[Date]&lt;/STRONG&gt;&lt;/FONT&gt;, which I assumed was sufficient to give the same granularity as the table visual in your screenshot. You can change these to a list of whatever columns are required to define the granularity for calculating the measure.&lt;/LI&gt;
&lt;LI&gt;&lt;STRONG&gt;&lt;FONT face="courier new,courier"&gt;[Fee Flag] = "High"&lt;/FONT&gt;&amp;nbsp;&lt;/STRONG&gt;can be replaced with any other condition you want to count involving a measure.&lt;/LI&gt;
&lt;/UL&gt;
&lt;P&gt;Does this work for you?&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Kind regards,&lt;/P&gt;
&lt;P&gt;Owen&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 11:16:28 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/3435993#M130374</guid>
      <dc:creator>OwenAuger</dc:creator>
      <dc:date>2023-09-18T11:16:28Z</dc:date>
    </item>
    <item>
      <title>Re: Count The Number of Times a Measure Returns a Specific Value</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/3436192#M130385</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="6799" data-lia-user-login="OwenAuger" class="lia-mention lia-mention-user"&gt;OwenAuger&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This worked 100% perfectly. Thank you so much!!&lt;/P&gt;</description>
      <pubDate>Mon, 18 Sep 2023 12:54:11 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Count-The-Number-of-Times-a-Measure-Returns-a-Specific-Value/m-p/3436192#M130385</guid>
      <dc:creator>Katie-Farrand12</dc:creator>
      <dc:date>2023-09-18T12:54:11Z</dc:date>
    </item>
  </channel>
</rss>

