<?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: DAX: Unwanted cartesian product lines? in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Unwanted-cartesian-product-lines/m-p/3013861#M102271</link>
    <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;Please&amp;nbsp;refer to attached sample file with the solution&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;lastDate = 
CALCULATE (
    LASTDATE ( tstTable[Date] ),
    REMOVEFILTERS ( tstTable[Date] ),
    CROSSFILTER ( tstTable[subType], dimType[subType], BOTH )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;rnkDate = 
VAR t =
    CALCULATETABLE (
        VALUES ( tstTable[Date] ),
        REMOVEFILTERS ( tstTable[Date] )
    )
VAR Result = 
    RANKX(
        t,
        CALCULATE ( MAX ( tstTable[Date] ) )
    )
RETURN
    IF ( 
        NOT ISEMPTY ( tstTable ),
        Result
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Wed, 11 Jan 2023 13:33:31 GMT</pubDate>
    <dc:creator>tamerj1</dc:creator>
    <dc:date>2023-01-11T13:33:31Z</dc:date>
    <item>
      <title>DAX: Unwanted cartesian product lines?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Unwanted-cartesian-product-lines/m-p/3013796#M102263</link>
      <description>&lt;DIV class=""&gt;&lt;DIV class=""&gt;&amp;nbsp;&lt;/DIV&gt;&lt;/DIV&gt;&lt;DIV class=""&gt;&lt;DIV class=""&gt;&lt;P&gt;Please help to calculate/understand properly&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;lastDate&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;and&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;rankDate&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;measures for following simplified example (&lt;A href="https://github.com/DenisSipchenko/Power-BI/blob/main/Questions/DAX_UnwantedRows.pbix" target="_blank" rel="nofollow noopener noreferrer"&gt;download&lt;/A&gt;) :&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;Desired result:&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Reality (incorrect subtypes):&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;Why relationship is broken?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&lt;STRONG&gt;How to avoid this cartesian product lines?&lt;/STRONG&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My Measure (I commented workaround, because it's kind of postfilter, not prefilter):&lt;/P&gt;&lt;PRE&gt;rnkDate = 
VAR t =
    CALCULATETABLE(
        VALUES(tstTable[Date]),
        REMOVEFILTERS(tstTable[Date])
    )
RETURN 
    //IF( MAX(tstTable[Amount])&amp;lt;&amp;gt;BLANK(), // WORKAROUND To hide unwantedd rows
        RANKX(
            t,
            LASTDATE(tstTable[Date])
        )
    //)&lt;/PRE&gt;&lt;P&gt;&lt;STRONG&gt;P.S.&lt;/STRONG&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;Mess happens only if I use fields from dimensional table&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;dimType[Type]&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;(within one table everything is Ok):&lt;/P&gt;&lt;DIV class=""&gt;&lt;img /&gt;&lt;/DIV&gt;&lt;/DIV&gt;&lt;/DIV&gt;</description>
      <pubDate>Wed, 11 Jan 2023 14:16:26 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Unwanted-cartesian-product-lines/m-p/3013796#M102263</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-01-11T14:16:26Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Unwanted cartesian product lines?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Unwanted-cartesian-product-lines/m-p/3013861#M102271</link>
      <description>&lt;P&gt;Hi&amp;nbsp;Anonymous&lt;/LI-USER&gt;&amp;nbsp;&lt;BR /&gt;Please&amp;nbsp;refer to attached sample file with the solution&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;
&lt;LI-CODE lang="javascript"&gt;lastDate = 
CALCULATE (
    LASTDATE ( tstTable[Date] ),
    REMOVEFILTERS ( tstTable[Date] ),
    CROSSFILTER ( tstTable[subType], dimType[subType], BOTH )
)&lt;/LI-CODE&gt;&lt;LI-CODE lang="javascript"&gt;rnkDate = 
VAR t =
    CALCULATETABLE (
        VALUES ( tstTable[Date] ),
        REMOVEFILTERS ( tstTable[Date] )
    )
VAR Result = 
    RANKX(
        t,
        CALCULATE ( MAX ( tstTable[Date] ) )
    )
RETURN
    IF ( 
        NOT ISEMPTY ( tstTable ),
        Result
    )&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Wed, 11 Jan 2023 13:33:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Unwanted-cartesian-product-lines/m-p/3013861#M102271</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-01-11T13:33:31Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Unwanted cartesian product lines?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Unwanted-cartesian-product-lines/m-p/3016169#M102432</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;&amp;nbsp;, thank you for your feedback.&lt;BR /&gt;&lt;BR /&gt;&lt;/P&gt;&lt;OL&gt;&lt;LI&gt;Regarding &lt;STRONG&gt;lastDate&lt;/STRONG&gt;, as far as I understand crossfilter is not necessary. And &lt;A href="https://community.powerbi.com/t5/Desktop/Two-identical-visuals-with-different-output-how-it-s-possible/m-p/3014561#M1027687" target="_self"&gt;here&lt;/A&gt; is more important question for me regarding this measure&amp;nbsp;&lt;/LI&gt;&lt;LI&gt;Regarding &lt;STRONG&gt;rnkDate&lt;/STRONG&gt;, the question is why it returns cartesian product for subTypes if we do NOT use if statement? Is it normal?&lt;BR /&gt;&lt;STRONG&gt;NB!&lt;/STRONG&gt; it's NOT about empty values, it's about CARTESIAN product&lt;BR /&gt;&amp;nbsp;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;LI&gt;A bit of topic: how do you attach .pbix direcctly in post? When I try drag&amp;amp;drop&lt;BR /&gt;&lt;img /&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;/LI&gt;&lt;/OL&gt;</description>
      <pubDate>Thu, 12 Jan 2023 08:55:14 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Unwanted-cartesian-product-lines/m-p/3016169#M102432</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2023-01-12T08:55:14Z</dc:date>
    </item>
    <item>
      <title>Re: DAX: Unwanted cartesian product lines?</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Unwanted-cartesian-product-lines/m-p/3016567#M102455</link>
      <description>&lt;P&gt;Anonymous&lt;/a&gt;&amp;nbsp;&lt;BR /&gt;1. Yes you are right.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;2. The issue is related to the filter context. One column of the fact table (the [Date] column) is used in the matrix therefore, it's part of the filter context. In this case the filter context created by the engine is the CROSSJOIN between the SUMMARIZE ( dimType,&amp;nbsp;dimType[Type], dimType[subType] ) and DISTINCT (&amp;nbsp;tstTable[Date] ) which generates all the possible combinations between the two tables.&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When placing a normal aggregation measure in the matrix the engine checks first if the value is blank then it hides it. With RANKX things are different and the reason is that even the balnk value will have a rank (because DAX considers blank as zero in calculations) and the rank cannot be blank rather it will be the samllest or the largest rank value depending on the sort oreder of RANKX.&lt;/P&gt;
&lt;P&gt;3. You can upload to DropBox or OneDrive and share the download link.&lt;/P&gt;</description>
      <pubDate>Thu, 12 Jan 2023 11:11:54 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-Unwanted-cartesian-product-lines/m-p/3016567#M102455</guid>
      <dc:creator>tamerj1</dc:creator>
      <dc:date>2023-01-12T11:11:54Z</dc:date>
    </item>
  </channel>
</rss>

