<?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 calculate with filters from two different dimensions in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculate-with-filters-from-two-different-dimensions/m-p/917259#M8932</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="203369" data-lia-user-login="Lannersten" class="lia-mention lia-mention-user"&gt;Lannersten&lt;/a&gt;&amp;nbsp;Please try below measure and check if it works for you.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure = 
VAR _customerId = SELECTEDVALUE('Fact'[CustomerId])
VAR _deathdate = CALCULATE(MAX(DimCustomer[Deathdate]),DimCustomer[CustomerId]=_customerId)
RETURN CALCULATE(DISTINCTCOUNT('Fact'[CustomerId]),'Fact'[Amount]&amp;gt;0,Dim_Date[To]&amp;lt;_deathdate)&lt;/LI-CODE&gt;</description>
    <pubDate>Fri, 31 Jan 2020 03:46:49 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2020-01-31T03:46:49Z</dc:date>
    <item>
      <title>DAX calculate with filters from two different dimensions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculate-with-filters-from-two-different-dimensions/m-p/917057#M8929</link>
      <description>&lt;P&gt;Hi&lt;/P&gt;&lt;P&gt;Suppose that you want to count your customers&lt;/P&gt;&lt;P&gt;And that you just want to count those that has money in their account&amp;nbsp; (This filter is easy and is applied in my code sample)&lt;/P&gt;&lt;P&gt;And sadly some of your customers pass away and you just want to count them as long as their alive (Scary ?)&lt;/P&gt;&lt;P&gt;In my sample I have tried to visualize what I am expecting.&lt;/P&gt;&lt;P&gt;My problem is in that I need to filter rows in my result based on if the customer is alive at this specific time or not.&lt;BR /&gt;The dateofdeath is in Dim_Customer, and present time is in Dim_Date, my filter would be something like Dim_Customer[DateOfDeath] &amp;gt; Dim_Date[PeriodDateTo] But this gives an error&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;SO how would you solve this problem?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best Regards, Joakim&lt;img /&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 30 Jan 2020 22:50:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculate-with-filters-from-two-different-dimensions/m-p/917057#M8929</guid>
      <dc:creator>Lannersten</dc:creator>
      <dc:date>2020-01-30T22:50:24Z</dc:date>
    </item>
    <item>
      <title>Re: DAX calculate with filters from two different dimensions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculate-with-filters-from-two-different-dimensions/m-p/917259#M8932</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="203369" data-lia-user-login="Lannersten" class="lia-mention lia-mention-user"&gt;Lannersten&lt;/a&gt;&amp;nbsp;Please try below measure and check if it works for you.&lt;/P&gt;&lt;LI-CODE lang="markup"&gt;Measure = 
VAR _customerId = SELECTEDVALUE('Fact'[CustomerId])
VAR _deathdate = CALCULATE(MAX(DimCustomer[Deathdate]),DimCustomer[CustomerId]=_customerId)
RETURN CALCULATE(DISTINCTCOUNT('Fact'[CustomerId]),'Fact'[Amount]&amp;gt;0,Dim_Date[To]&amp;lt;_deathdate)&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 31 Jan 2020 03:46:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculate-with-filters-from-two-different-dimensions/m-p/917259#M8932</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2020-01-31T03:46:49Z</dc:date>
    </item>
    <item>
      <title>Re: DAX calculate with filters from two different dimensions</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculate-with-filters-from-two-different-dimensions/m-p/918157#M8950</link>
      <description>&lt;P&gt;Hi Vimal&lt;/P&gt;&lt;P&gt;I had an issue with the selectedvalue formula in Excel, but I retyped it like this:&lt;/P&gt;&lt;P&gt;NumOfCustomersAlive:=VAR _customerId = IF(HASONEVALUE('Facts'[CustomerId]);VALUES('Facts'[CustomerId]))&lt;BR /&gt;VAR _deathdate = CALCULATE(MAX(Dim_Customer[CalculatedDateOfDeath]);Dim_Customer[CustomerId]=_customerId)&lt;BR /&gt;RETURN CALCULATE(DISTINCTCOUNT('Facts'[CustomerId]);'Facts'[Amount]&amp;gt;0;Dim_Date[PeriodDatumTo]&amp;lt;_deathdate)&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;And it made the job, but when I added one more CustomerId to my facts table,&amp;nbsp; the code fails. I guess it has to do with VAR _customerid just keeps&amp;nbsp; one value ? Or? (In my production environment I have a couple of millions of customers...)&lt;/P&gt;&lt;P&gt;I have attached the result and my expected result + The data I'm using.&lt;/P&gt;&lt;P&gt;Do you suggest some other tweak to my code?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Best, Joakim&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 31 Jan 2020 17:11:38 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/DAX-calculate-with-filters-from-two-different-dimensions/m-p/918157#M8950</guid>
      <dc:creator>Lannersten</dc:creator>
      <dc:date>2020-01-31T17:11:38Z</dc:date>
    </item>
  </channel>
</rss>

