<?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 MEDIANX Returning Incorrect Value with ALLSELECTED in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3557628#M136990</link>
    <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've included all sample data and key DAX formulas &lt;A href="https://1drv.ms/x/s!ApiFb_juj94X9lEnHdJWMEyqD6iF?e=ShjQHw" target="_self"&gt;here&lt;/A&gt;. My question is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a KPI [% Release Completed Points] which is [# of Release Completed Points] /&amp;nbsp;[# of Release Loaded Points]. I am trying to calculate the MEDIAN for whichever Releases and Teams a user selects. No matter what I seem to try, I am not getting correct values. My latest attempts is as follows, but it is not working:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR _SelectedReleased = ALLSELECTED ( Releases[Release] )
VAR _SelectedTeams =
    FILTER (
        ALLSELECTED ( 'Delivery Team'[Delivery Team] ),
        'Delivery Team'[Delivery Team] &amp;lt;&amp;gt; "Team 7"
    )
VAR _AllRows =
    CROSSJOIN (
        _SelectedReleased,
        _SelectedTeams
    )
VAR _Result =
    MEDIANX (
        _AllRows,
        CALCULATE (
            [% Release Completed Points],
            _SelectedReleased,
            _SelectedTeams
        )
    )
RETURN
    _Result&lt;/LI-CODE&gt;&lt;P&gt;Any guidance on where I am going wrong would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help you can provide.&lt;/P&gt;</description>
    <pubDate>Wed, 29 Nov 2023 01:02:17 GMT</pubDate>
    <dc:creator>msmays5</dc:creator>
    <dc:date>2023-11-29T01:02:17Z</dc:date>
    <item>
      <title>MEDIANX Returning Incorrect Value with ALLSELECTED</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3557628#M136990</link>
      <description>&lt;P&gt;Hi all,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I've included all sample data and key DAX formulas &lt;A href="https://1drv.ms/x/s!ApiFb_juj94X9lEnHdJWMEyqD6iF?e=ShjQHw" target="_self"&gt;here&lt;/A&gt;. My question is as follows:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have a KPI [% Release Completed Points] which is [# of Release Completed Points] /&amp;nbsp;[# of Release Loaded Points]. I am trying to calculate the MEDIAN for whichever Releases and Teams a user selects. No matter what I seem to try, I am not getting correct values. My latest attempts is as follows, but it is not working:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR _SelectedReleased = ALLSELECTED ( Releases[Release] )
VAR _SelectedTeams =
    FILTER (
        ALLSELECTED ( 'Delivery Team'[Delivery Team] ),
        'Delivery Team'[Delivery Team] &amp;lt;&amp;gt; "Team 7"
    )
VAR _AllRows =
    CROSSJOIN (
        _SelectedReleased,
        _SelectedTeams
    )
VAR _Result =
    MEDIANX (
        _AllRows,
        CALCULATE (
            [% Release Completed Points],
            _SelectedReleased,
            _SelectedTeams
        )
    )
RETURN
    _Result&lt;/LI-CODE&gt;&lt;P&gt;Any guidance on where I am going wrong would be greatly appreciated.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks in advance for any help you can provide.&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 01:02:17 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3557628#M136990</guid>
      <dc:creator>msmays5</dc:creator>
      <dc:date>2023-11-29T01:02:17Z</dc:date>
    </item>
    <item>
      <title>Re: MEDIANX Returning Incorrect Value with ALLSELECTED</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3557942#M137016</link>
      <description>&lt;P&gt;Here's a modified version of your DAX code:&lt;/P&gt;&lt;P&gt;VAR _SelectedReleased = ALLSELECTED ( Releases[Release] )&lt;BR /&gt;VAR _SelectedTeams =&lt;BR /&gt;VALUES (&lt;BR /&gt;'Delivery Team'[Delivery Team]&lt;BR /&gt;)&lt;BR /&gt;VAR _AllRows =&lt;BR /&gt;CROSSJOIN (&lt;BR /&gt;_SelectedReleased,&lt;BR /&gt;_SelectedTeams&lt;BR /&gt;)&lt;BR /&gt;VAR _Result =&lt;BR /&gt;MEDIANX (&lt;BR /&gt;_AllRows,&lt;BR /&gt;CALCULATE (&lt;BR /&gt;[% Release Completed Points],&lt;BR /&gt;_SelectedReleased,&lt;BR /&gt;_SelectedTeams&lt;BR /&gt;)&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;_Result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;Changes made:&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Use VALUES() instead of FILTER():&lt;/STRONG&gt; Instead of using FILTER to exclude "Team 7", I've used VALUES to get all the selected teams. This will automatically exclude "Team 7" and give you a distinct list of selected teams.&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;&lt;P&gt;&lt;STRONG&gt;Changed _SelectedTeams in the CALCULATE function:&lt;/STRONG&gt; I changed _SelectedTeams to use VALUES() in the CALCULATE function. This ensures that the context transition works correctly when calculating [% Release Completed Points] for each row in _AllRows.&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;&lt;P&gt;Give this a try and see if it produces the desired result. If you're still facing issues, please provide more details about the data model and the structure of your tables, and I'll do my best to assist you further.&lt;/P&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 29 Nov 2023 05:31:02 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3557942#M137016</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-11-29T05:31:02Z</dc:date>
    </item>
    <item>
      <title>Re: MEDIANX Returning Incorrect Value with ALLSELECTED</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3559470#M137141</link>
      <description>&lt;P&gt;Thank you for your willingness to help! However, there are two issues I'm encountering:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;1. My measure was misnamed -- it should be the Median across both the selected teams and the selected releases - so I believe I should be using ALLSELECTED(Deliver Team[Delivery Team])&amp;nbsp;&lt;/P&gt;&lt;P&gt;2. When I implemented your code, I was still not getting the correct median, even when just looking across releases. I'm getting the same value for both the base measure and the median measure. Please see &lt;A href="https://1drv.ms/i/s!ApiFb_juj94X9lLqIjDuNJUs6qAi?e=h8UKns" target="_self"&gt;here&lt;/A&gt; for a visual of what I'm seeing. Could this have something to do with the base measure having a KEEPFILTERS in it?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks again for your assistance&lt;/P&gt;</description>
      <pubDate>Wed, 29 Nov 2023 17:30:27 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3559470#M137141</guid>
      <dc:creator>msmays5</dc:creator>
      <dc:date>2023-11-29T17:30:27Z</dc:date>
    </item>
    <item>
      <title>Re: MEDIANX Returning Incorrect Value with ALLSELECTED</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3560341#M137213</link>
      <description>&lt;P&gt;If you want to calculate the median across both selected teams and selected releases, you can use ALLSELECTED on both dimensions. Also, the issue you're facing might be related to the KEEPFILTERS in the base measure.&lt;/P&gt;&lt;P&gt;Let's modify the formula to address these concerns:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;VAR _Result =&lt;BR /&gt;MEDIANX(&lt;BR /&gt;ALLSELECTED(Releases[Release], 'Delivery Team'[Delivery Team]),&lt;BR /&gt;[% Release Completed Points]&lt;BR /&gt;)&lt;/P&gt;&lt;P&gt;RETURN&lt;BR /&gt;_Result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;This modification uses ALLSELECTED on both the Releases and Delivery Team dimensions within the MEDIANX function.&lt;/P&gt;&lt;P&gt;Regarding the issue with the base measure containing KEEPFILTERS, it depends on the context and the logic within the base measure. If the base measure uses KEEPFILTERS in a way that interferes with the calculation of the median, you might need to modify the base measure as well.&lt;/P&gt;&lt;P&gt;If the base measure is using KEEPFILTERS to enforce a specific context, you may need to adjust your base measure logic to work well with the overall calculation. Alternatively, you can provide more details about your base measure, and I can assist you in modifying it if necessary.&lt;/P&gt;&lt;P&gt;Please make sure to replace [% Release Completed Points] with the actual expression you are using for calculating the release completed points.&lt;/P&gt;&lt;P&gt;If you still encounter issues, please provide more details about the base measure, and I'll do my best to assist you further.&lt;/P&gt;</description>
      <pubDate>Thu, 30 Nov 2023 07:05:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3560341#M137213</guid>
      <dc:creator>123abc</dc:creator>
      <dc:date>2023-11-30T07:05:20Z</dc:date>
    </item>
    <item>
      <title>Re: MEDIANX Returning Incorrect Value with ALLSELECTED</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3567491#M137527</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="207035" data-lia-user-login="msmays5" class="lia-mention lia-mention-user"&gt;msmays5&lt;/a&gt;&amp;nbsp;,&lt;BR /&gt;&lt;BR /&gt;Have you solved your problem? If solved please mark the reply in this post which you think is helpful as a solution to help more others facing the same problem to find a solution quickly, thank you very much!&lt;BR /&gt;&lt;BR /&gt;Best Regards,&lt;BR /&gt;Dino Tao&lt;/P&gt;</description>
      <pubDate>Tue, 05 Dec 2023 03:09:20 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3567491#M137527</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-12-05T03:09:20Z</dc:date>
    </item>
    <item>
      <title>Re: MEDIANX Returning Incorrect Value with ALLSELECTED</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3580226#M138080</link>
      <description>&lt;P&gt;Apologies for the delay in getting back to you, I've been out of pocket. Thank you for following up.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;In your example, I recieve the error: "All column arguments of the ALL/ALLNOBLANKROW/ALLSELECTED/REMOVEFILTERS function must be from the same table."&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Additionally, I've moved my base measure to the median calculation, hoping that would resolve the issue, but I'm still getting incorrect results:&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;VAR _SelectedReleased = ALLSELECTED ( Releases[Release] )
VAR _SelectedTeams = ALLSELECTED ( 'Delivery Team'[Delivery Team] )
VAR _AllRows =
    CROSSJOIN(
        _SelectedReleased,
        _SelectedTeams
    )
VAR _Result =
    MEDIANX (
        _AllRows,
        VAR _Nume = 
            CALCULATE ( 
                [# of Release Completed Points], 
                REMOVEFILTERS ( Releases ), 
                _SelectedReleased,
                REMOVEFILTERS ( 'Delivery Team' ),
                _SelectedTeams
            )
        VAR _Denom = 
            CALCULATE( 
                [# of Release Loaded Points], 
                REMOVEFILTERS ( Releases ), 
                _SelectedReleased,
                REMOVEFILTERS ( 'Delivery Team' ),
                _SelectedTeams
            )
        VAR _Result2 = DIVIDE ( _Nume, _Denom )
        RETURN
            _Result2
    )
RETURN
    _Result&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 12 Dec 2023 16:35:01 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/MEDIANX-Returning-Incorrect-Value-with-ALLSELECTED/m-p/3580226#M138080</guid>
      <dc:creator>msmays5</dc:creator>
      <dc:date>2023-12-12T16:35:01Z</dc:date>
    </item>
  </channel>
</rss>

