<?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: Calculated column returning the majority across a number of rows in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3053996#M105291</link>
    <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="399872" data-lia-user-login="Tob_P" class="lia-mention lia-mention-user"&gt;Tob_P&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by Grouping and can you describe your detailed steps?&lt;/P&gt;
&lt;P&gt;I can't tell where the problem is just by the description of "Grouping".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jianbo Li&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
    <pubDate>Wed, 01 Feb 2023 01:22:43 GMT</pubDate>
    <dc:creator>v-jianboli-msft</dc:creator>
    <dc:date>2023-02-01T01:22:43Z</dc:date>
    <item>
      <title>Calculated column returning the majority across a number of rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3047001#M104774</link>
      <description>&lt;P&gt;Hello.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have my Purchase Line table detailing deliveries. Each delivery has it's own unique number but there can be multiple deliveries for each number (as little as 1, as many as 8). In the same table there is a Delivery Day column, so for each line there can be any of the following...&lt;/P&gt;&lt;UL&gt;&lt;LI&gt;Blank (not delivered)&lt;/LI&gt;&lt;LI&gt;1 (delivered on 1st day)&lt;/LI&gt;&lt;LI&gt;2 (delivered on 2nd day)&lt;/LI&gt;&lt;LI&gt;3 (delivered on 3rd day)&lt;/LI&gt;&lt;LI&gt;4 (delivered early)&lt;/LI&gt;&lt;LI&gt;5 (delivered late)&lt;/LI&gt;&lt;/UL&gt;&lt;P&gt;I need to create a calculated column which identifies blank, 1 &amp;amp; 4 as 1 (or Day 1), 2 as 2 (or Day 2), 3 as 3 (or Day 3) and 5 as 5 (or Late) with the following condition - the majority eg. number of lines with a value greater than 50% gets the credit. So if there is one unique ID and Delivery Day column has five lines (deliveries), and 3 of them are Day 1 and 2 of them are Day 2, then Day 1 gets the "credit'. See example...&lt;/P&gt;&lt;TABLE&gt;&lt;TBODY&gt;&lt;TR&gt;&lt;TD&gt;Load No&lt;/TD&gt;&lt;TD&gt;Delivery Day&lt;/TD&gt;&lt;TD&gt;Desired Output&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L555111&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L555111&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L555111&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L555111&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L555111&lt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/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L555444&lt;/TD&gt;&lt;TD&gt;2&lt;/TD&gt;&lt;TD&gt;1&lt;/TD&gt;&lt;/TR&gt;&lt;TR&gt;&lt;TD&gt;L555444&lt;/TD&gt;&lt;TD&gt;2&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;In the event of a tie eg. L555222 which has two Day 2 and two Day 3 deliveries, then the earliest day (or lowest value) gets the 'credit'&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have given this a go in Groups but that can't take into account differences in Delivery Days across the lines, also tried rank/topN and MAX in Measures but feel that the solution is probably either in a calculated column or a Custom Column in Query Editor, but this one is just beyond my capability in that regard. Any guidance appreciated on online resources that can help point me in the right direction to research this.&lt;/P&gt;</description>
      <pubDate>Fri, 27 Jan 2023 10:43:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3047001#M104774</guid>
      <dc:creator>Tob_P</dc:creator>
      <dc:date>2023-01-27T10:43:20Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column returning the majority across a number of rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3048948#M104934</link>
      <description>&lt;P&gt;Bumping this up to see if anyone able to help - two days of working away on it myself with no real headway! Appreciate any guidance. Thanks&lt;/P&gt;</description>
      <pubDate>Sun, 29 Jan 2023 14:33:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3048948#M104934</guid>
      <dc:creator>Tob_P</dc:creator>
      <dc:date>2023-01-29T14:33:52Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column returning the majority across a number of rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3049015#M104941</link>
      <description>&lt;P&gt;Perhaps a simpler way of me expressing what I'm looking for is..&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;If the count of the value in Delivery Day is greater than 50% or .5, then return that value for each Delivery Number.&lt;/P&gt;</description>
      <pubDate>Sun, 29 Jan 2023 16:35:09 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3049015#M104941</guid>
      <dc:creator>Tob_P</dc:creator>
      <dc:date>2023-01-29T16:35:09Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column returning the majority across a number of rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3051718#M105136</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="399872" data-lia-user-login="Tob_P" class="lia-mention lia-mention-user"&gt;Tob_P&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Please try:&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Column =
VAR _a =
    COUNTROWS ( FILTER ( 'Table', [Load No] = EARLIER ( 'Table'[Load No] ) ) )
VAR _b =
    SUMMARIZE (
        FILTER ( 'Table', [Load No] = EARLIER ( 'Table'[Load No] ) ),
        'Table'[Delivery Day],
        "Day", IF ( [Delivery Day] IN { 0, 1, 4 }, 1, [Delivery Day] ),
        "Count", COUNT ( 'Table'[Delivery Day] )
    )
VAR _c =
    SUMMARIZE (
        _b,
        [Day],
        [Count],
        "Flag",
            SWITCH (
                TRUE (),
                SUMX ( _b, [Count] ) &amp;gt; ( 0.5 * _a ), 1,
                SUMX ( _b, [Count] ) = ( 0.5 * _a )
                    &amp;amp;&amp;amp; [Day] = MINX ( _b, [Day] ), 1
            )
    )
RETURN
    MINX ( FILTER ( _c, [Flag] = 1 ), [Day] )
&lt;/LI-CODE&gt;
&lt;P&gt;Final output:&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;/P&gt;
&lt;P style="background: white; margin: 7.5pt 0in 0in 0in;"&gt;&lt;SPAN&gt;Best Regards,&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background: white; margin: 7.5pt 0in 0in 0in;"&gt;&lt;SPAN&gt;Jianbo Li&lt;/SPAN&gt;&lt;/P&gt;
&lt;P style="background: white; margin: 7.5pt 0in 0in 0in;"&gt;&lt;SPAN&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;helps&lt;/I&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;I&gt;Accept it as the solution&lt;/I&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 05:17:25 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3051718#M105136</guid>
      <dc:creator>v-jianboli-msft</dc:creator>
      <dc:date>2023-01-31T05:17:25Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column returning the majority across a number of rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3052684#M105201</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="403972" data-lia-user-login="v-jianboli-msft" class="lia-mention lia-mention-user"&gt;v-jianboli-msft&lt;/a&gt;Thank you for your response - it's really appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I think that this will give me what I want, but perhaps you can tell me why it would not work if I used Groupings?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 31 Jan 2023 13:02:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3052684#M105201</guid>
      <dc:creator>Tob_P</dc:creator>
      <dc:date>2023-01-31T13:02:02Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column returning the majority across a number of rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3053996#M105291</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="399872" data-lia-user-login="Tob_P" class="lia-mention lia-mention-user"&gt;Tob_P&lt;/a&gt;&amp;nbsp;,&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;What do you mean by Grouping and can you describe your detailed steps?&lt;/P&gt;
&lt;P&gt;I can't tell where the problem is just by the description of "Grouping".&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;/P&gt;
&lt;P&gt;Jianbo Li&lt;/P&gt;
&lt;P&gt;If this post&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;helps&lt;/EM&gt;&lt;/STRONG&gt;, then please consider&amp;nbsp;&lt;STRONG&gt;&lt;EM&gt;Accept it as the solution&lt;/EM&gt;&lt;/STRONG&gt;&amp;nbsp;to help the other members find it more quickly.&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 01:22:43 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3053996#M105291</guid>
      <dc:creator>v-jianboli-msft</dc:creator>
      <dc:date>2023-02-01T01:22:43Z</dc:date>
    </item>
    <item>
      <title>Re: Calculated column returning the majority across a number of rows</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3054503#M105319</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="403972" data-lia-user-login="v-jianboli-msft" class="lia-mention lia-mention-user"&gt;v-jianboli-msft&lt;/a&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I used groupings in the Data view based in your calculated column (I had to replace 5 with 4 in your DAX)...&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;..then applied a measure giving the count of the rows in the table which gave the output of everything in Day 1. Is it the case that this calculated column cannot be grouped?&lt;/P&gt;</description>
      <pubDate>Wed, 01 Feb 2023 07:26:55 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Calculated-column-returning-the-majority-across-a-number-of-rows/m-p/3054503#M105319</guid>
      <dc:creator>Tob_P</dc:creator>
      <dc:date>2023-02-01T07:26:55Z</dc:date>
    </item>
  </channel>
</rss>

