<?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: Calculating sum/count of nested if satements in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4033171#M159643</link>
    <description>&lt;P&gt;Depending on the dimension you want the percentage over:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;Green % =
VAR __Colors =
    ADDCOLUMNS (
        DISTINCT ( Table[Dimension] ),
        "@Color", [ColorMeasure]
    )
VAR __Green = COUNTROWS ( FILTER ( __Colors, [@Color] = "Green" ) )
VAR __All   = COUNTROWS ( __Colors )
RETURN
    DIVIDE ( __Green, __All )&lt;/LI-CODE&gt;</description>
    <pubDate>Tue, 09 Jul 2024 20:00:03 GMT</pubDate>
    <dc:creator>AlexisOlson</dc:creator>
    <dc:date>2024-07-09T20:00:03Z</dc:date>
    <item>
      <title>Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4032820#M159613</link>
      <description>&lt;P&gt;I have a long nested IF-statement measure that I use to colour a heatmap that I have. (Green, Yellow and Red)&lt;/P&gt;&lt;P&gt;However, I want to reuse this (if possible) to instead calculated the percentage that is green.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The measure I created to generate the colours: (but with colourcodes instead)&lt;/P&gt;&lt;LI-SPOILER&gt;&lt;LI-CODE lang="markup"&gt;ColorMeasure = 
VAR xValue = [Sold Average]
VAR yValue = [Open Average]
RETURN
IF(
    yValue = 1,
    IF(
        xValue &amp;lt; 171, 
        "Green",
        IF(
            ABS(xValue - 171) &amp;lt;= 0.1 * 171,
            "Yellow",
            IF(
                xValue &amp;gt; 171,
                "RED",
                BLANK()
            )
        )
    ),
    IF(
        yValue = 2,
        IF(
            xValue &amp;gt;= 172 &amp;amp;&amp;amp; xValue &amp;lt;= 257,
            "Green",
            IF(
                xValue &amp;gt;= 172 * 0.9 &amp;amp;&amp;amp; xValue &amp;lt;= 257 * 1.1,
                "Yellow",
                "RED"
            )
        ),
        IF(
            yValue = 3,
            IF(
                xValue &amp;gt;= 258 &amp;amp;&amp;amp; xValue &amp;lt;= 490,
                "Green",
                IF(
                    xValue &amp;gt;= 258 * 0.9 &amp;amp;&amp;amp; xValue &amp;lt;= 490 * 1.1,
                    "Yellow",
                    "RED"
                )
            ),
            IF(
                yValue = 4,
                IF(
                    xValue &amp;gt; 491,
                    "Green",
                    IF(
                        xValue &amp;gt;= 491 * 0.9,
                        "Yellow",
                        "RED"
                    )
                ),
                BLANK()
            )
        )
    )
)&lt;/LI-CODE&gt;&lt;/LI-SPOILER&gt;&lt;P&gt;So what I want to do it is something like this&lt;/P&gt;&lt;P&gt;Divide(_GreenCount,(_GreenCount+_YellowCount+_RedCount))&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;But I'm not sure how to do the _GreenCount&lt;/P&gt;&lt;P&gt;I've tried using something like:&amp;nbsp;&lt;/P&gt;&lt;P&gt;SUMX(&lt;BR /&gt;'TableA',&lt;BR /&gt;IF([ColorMeasure] = "Green", 1, 0)&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;But this just gives me 0 &lt;span class="lia-unicode-emoji" title=":confused_face:"&gt;😕&lt;/span&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;worth noting maybe is that xValue and yValue come from two different fact tables&lt;/P&gt;</description>
      <pubDate>Tue, 09 Jul 2024 15:21:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4032820#M159613</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-09T15:21:30Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4033171#M159643</link>
      <description>&lt;P&gt;Depending on the dimension you want the percentage over:&lt;BR /&gt;&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;Green % =
VAR __Colors =
    ADDCOLUMNS (
        DISTINCT ( Table[Dimension] ),
        "@Color", [ColorMeasure]
    )
VAR __Green = COUNTROWS ( FILTER ( __Colors, [@Color] = "Green" ) )
VAR __All   = COUNTROWS ( __Colors )
RETURN
    DIVIDE ( __Green, __All )&lt;/LI-CODE&gt;</description>
      <pubDate>Tue, 09 Jul 2024 20:00:03 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4033171#M159643</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2024-07-09T20:00:03Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4034017#M159736</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks for the reply and assist!&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried this suggestion but I can't get it right,&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried a various number of Table[Dimension] but none seems to get it working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue I have is that it just returns BLANK when it's a red or yellow hour.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've tried using the ColorMeausure I wrote in the original post to verify that it produces the expected result and it does.&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;But the "Green %" measure returns the following:&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;So only the green numbers appear.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which I actually want to display through a card visual, but that just says "Blank"&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;</description>
      <pubDate>Wed, 10 Jul 2024 07:50:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4034017#M159736</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-10T07:50:33Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4034946#M159882</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I have filter for one store, and one week and I take out the _All from the calculation you sent.&amp;nbsp;&lt;/P&gt;&lt;P&gt;I get the result of "24", which makes sense since there are 24 hours in a day. But not 24 hours in a week.&amp;nbsp;&lt;/P&gt;&lt;P&gt;In fact I expect the number of hours to be 149, since that's how many hours we're open in that week.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So I think the issue is that I'm using the wrong dimension here:&lt;/P&gt;&lt;PRE&gt;VAR __Colors =
    ADDCOLUMNS (
        DISTINCT ( Table[Dimension] ),
        "@Color", [ColorMeasure]
    )&lt;/PRE&gt;&lt;P&gt;because the dimension I use, which is the one I also use in the visualisation only have 24 hours.&amp;nbsp;&lt;/P&gt;&lt;P&gt;BUT, none of the other I've tried work.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Not the fact table with all the xValue, not the fact table with yValue, or the date table...&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I in my matrix select just one day, it shows the correct number of open hours with "_All"&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If I then try "_Green" instead, it gives me a BLANK, unless I choose one specific hour, then it works...&lt;/P&gt;</description>
      <pubDate>Wed, 10 Jul 2024 14:48:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4034946#M159882</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-10T14:48:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4039848#M160179</link>
      <description>&lt;P&gt;Yep. The dimension is the issue.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;I think you need something like&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;VAR __Colors =
    ADDCOLUMNS (
        SUMMARIZE ( TableA, TableA[Date], TableA[Hour] ),
        "@Color", [ColorMeasure]
    )&lt;/LI-CODE&gt;
&lt;P&gt;I don't know exactly what tables and columns you have, so you need to adjust the SUMMARIZE columns for your specific model.&lt;/P&gt;</description>
      <pubDate>Fri, 12 Jul 2024 16:03:18 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4039848#M160179</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2024-07-12T16:03:18Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4059088#M161100</link>
      <description>&lt;P&gt;Hi,Anonymous&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;Has the problem been solved? If it does, share your solution and accept it as a solution that will help other community members who have the same problem as you.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Leroy Lu&lt;/P&gt;</description>
      <pubDate>Wed, 24 Jul 2024 13:08:41 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4059088#M161100</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-07-24T13:08:41Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4101898#M162768</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Sorry for the suuuuper late reply, I went on summer vacation&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yes, that sort of solved the issue, it's now calculating almost correctly.&amp;nbsp;&lt;/P&gt;&lt;P&gt;It is counting the correct number of green and total hours. BUT, for the whole selected period (like a month). But, in the heatmap I have that &lt;SPAN&gt;visualizes&amp;nbsp;&lt;/SPAN&gt;the greens and red in the original post, it's based on a weekly average. So, this means that the &lt;SPAN&gt;percentages&lt;/SPAN&gt;&amp;nbsp;that's &lt;SPAN&gt;calculated&amp;nbsp;&lt;/SPAN&gt;is not accurate to the heatmaps that's week based.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I do have a column for weeknumber, that I tried to add in the var __Colors above, but it's not &lt;SPAN&gt;changing&amp;nbsp;&lt;/SPAN&gt;the results.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 08:22:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4101898#M162768</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-15T08:22:01Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4102525#M162794</link>
      <description>&lt;P&gt;I wouldn't expect &lt;EM&gt;adding&lt;/EM&gt; week number to help. Try&amp;nbsp;&lt;EM&gt;recplacing&lt;/EM&gt; TableA[Date] with TableA[WeekNumber].&lt;/P&gt;</description>
      <pubDate>Thu, 15 Aug 2024 14:22:06 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4102525#M162794</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2024-08-15T14:22:06Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4103823#M162845</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yeah that's what I meant, sorry&lt;/P&gt;&lt;P&gt;But it didn't give me the correct result,&amp;nbsp;&lt;/P&gt;&lt;P&gt;for the example below:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;there is 131 filled boxes, 52 of which are green. Therefore I want to calculate 52/131 = 40% (39,6)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;With TableA[Date] in the measure, it counts 240/556&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;with TableA[WeekNumber] (instead of date) it gets down to 102/110&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 07:37:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4103823#M162845</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-16T07:37:49Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4104362#M162873</link>
      <description>&lt;P&gt;I can't tell what's going wrong from information I see in this thread.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Can you share a link to a .pbix? If not, at least specify exactly what your full DAX is and exactly what columns you're using in your matrix visual.&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 14:21:05 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4104362#M162873</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2024-08-16T14:21:05Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4104390#M162878</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yeah it's quite a complicated page&lt;/P&gt;&lt;P&gt;I'll do my best to explain. The heatmap has numbers ranging from 1-4, this is an average of TableCount[Count], this table has one row per hour per day that a store is open. And gives a number 1-4 based on a certain criteria.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;CALCULATE(
          ROUND( AVERAGE(TableCount[Count]), 0 ),
          TableCount[Count] &amp;lt;&amp;gt; 0
          )&lt;/LI-CODE&gt;&lt;P&gt;In the heatmap:&lt;/P&gt;&lt;P&gt;Rows is [Hour] column from dimension "Days"&lt;/P&gt;&lt;P&gt;Column is WeekDayName from dimension "Date"&lt;/P&gt;&lt;P&gt;and then measure above for values.&amp;nbsp;&lt;/P&gt;&lt;P&gt;This step is correct and verified&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The colours come from a very long if-statement measure that gives the colour based on another measure and depending if the matrix has 1 or 2 etc.&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for example, if sales is 100, then "[Count]" should be 1. and if that's the case in the matrix it gets a green colour.&lt;/P&gt;&lt;P&gt;This is also correct and verified&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;What I want to do is calculate the count of greens divided by the total number of colours in the matrix&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if there are a total of 10 green, red and yellow values, 5 of which are green then we should get 5/10 = 50%&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And this part technically works for the measure that's been created, however, it does so for the whole month that's been selected in a slicer, whereas the heatmap is only for a week. (averaged)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So if we only select one week in the slicer, we get a correct result, but more than that it's wrong.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So we need to summarize or average per week somewhere, which is where I get lost&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;</description>
      <pubDate>Fri, 16 Aug 2024 14:45:19 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4104390#M162878</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-16T14:45:19Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4104503#M162883</link>
      <description>&lt;P&gt;I think I might understand. It sounds like your percent green measure is using week number, which is a number 1-53 whereas the matrix visual is using WeekDayName Mon-Sun. To get the percentage you want, use the same dimensional granularity for the percentage measure as you have on your matrix visual. That is, use WeekDayName for both.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="php"&gt;SUMMARIZE ( TableCount, Dim_Date[WeekDayName], Dim_Day[Hour] )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 16 Aug 2024 15:27:00 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4104503#M162883</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2024-08-16T15:27:00Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4106348#M162953</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks!&lt;/P&gt;&lt;P&gt;Sadly this didn't give me the expected result, I got the same result I got when I used the weeknumber column actually&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;When I den count the number of greens I get 124 (it used to be 240). But the expected/correct outcome should be 52.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;How I count the green rows:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var _tbl = SUMMARIZE(
                    TableCount,
                    [WeekDayLong],
                    [Hour],
                    "_Colour", [ColourMeasure]
                    )
return

COUNTROWS(FILTER(_tbl, [_Colour] = "Green"))&lt;/LI-CODE&gt;&lt;DIV&gt;&amp;nbsp;&lt;/DIV&gt;</description>
      <pubDate>Mon, 19 Aug 2024 07:34:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4106348#M162953</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-19T07:34:26Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4107150#M162983</link>
      <description>&lt;P&gt;Unfortunately, I don't think I can debug any further without seeing your actual file.&lt;BR /&gt;&lt;BR /&gt;If you return &lt;A href="https://dax.guide/tocsv/" target="_self"&gt;TOCSV&lt;/A&gt; ( _tbl ), do the results match the granularity and values of your matrix?&lt;/P&gt;</description>
      <pubDate>Mon, 19 Aug 2024 14:46:39 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4107150#M162983</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2024-08-19T14:46:39Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4108645#M163043</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="39298" data-lia-user-login="AlexisOlson" class="lia-mention lia-mention-user"&gt;AlexisOlson&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Yeah I understand,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I tried&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var tbl = SUMMARIZE(
                    TableCount,
                    [WeekDayLong],
                    [Hour],
                    "_Colour", [ColorMeasure]
                    )
return
TOCSV(tbl)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and it returned the following, which looks weird to me&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And with just one week selected in the date slicer it also looks weird,&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;But if I instead return:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;COUNTROWS(FILTER(tbl, [_Colour] = "Green"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;it counts the correct greens rows (with just one week selected, it's when I use more weeks it get's weird).&lt;/P&gt;&lt;P&gt;Which is strange since it looks wrong in the TOCSV context.&lt;/P&gt;&lt;P&gt;Correct greens for one week should be 59, and 131 total&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Edit: Maybe a countrows is wrong now that we summarize per week instead.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Instead I should probably use SUM?&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 08:00:08 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4108645#M163043</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-20T08:00:08Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4109568#M163085</link>
      <description>&lt;P&gt;Those table previews seem OK to me at first glance (they only load 10 rows by default but you can use the optional arguments of the TOCSV function to load more). I can't tell what's going wrong.&lt;/P&gt;</description>
      <pubDate>Tue, 20 Aug 2024 15:47:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4109568#M163085</guid>
      <dc:creator>AlexisOlson</dc:creator>
      <dc:date>2024-08-20T15:47:42Z</dc:date>
    </item>
    <item>
      <title>Re: Calculating sum/count of nested if satements</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4110736#M163144</link>
      <description>&lt;P&gt;Ah, I exported all the rows just to check in excel quickly. There are 131 rows, which is perfect. BUT, 124 of them are considered green here, which is incorrect when only 52 should be considered green. (verified that 52 is the correct number, and that the measure that colours them green, red etc is also correct)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;So for:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;var tbl = SUMMARIZE(
                    TableCount,
                    [WeekDayLong],
                    [Hour],
                    "_Colour", [ColorMeasure]
                    )
return&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;This returns 131, which is correct:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;COUNTROWS(tbl)&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This returns 124, which is incorrect (52 expected)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;COUNTROWS(FILTER(tbl, [_Colour] = "Green"))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Which makes no sense, because when I use:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;   DIVIDE(
           COUNTROWS(FILTER(tbl, [Color] = "Green")),
           COUNTROWS(tbl)
           )&lt;/LI-CODE&gt;&lt;P&gt;I get 43%&lt;/P&gt;&lt;P&gt;and 124/131 isn't 43%... &lt;span class="lia-unicode-emoji" title=":grinning_face_with_smiling_eyes:"&gt;😄&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 21 Aug 2024 08:34:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculating-sum-count-of-nested-if-satements/m-p/4110736#M163144</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-08-21T08:34:07Z</dc:date>
    </item>
  </channel>
</rss>

