<?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 User Relationship function is not working in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Relationship-function-is-not-working/m-p/810154#M5182</link>
    <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to findout localdate from the date table based on the timezone matched with the fact table. I am using below dax but its not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CurrentDay =&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;SPAN&gt;VALUES(CalendarDate[LocalDateTime]), &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;USERELATIONSHIP(&lt;/SPAN&gt;&lt;SPAN&gt;Sales[TimeZone],&lt;/SPAN&gt;&lt;SPAN&gt;CalendarDate[TimeZone]&lt;/SPAN&gt;&lt;SPAN&gt; )&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have the calendarDate table having multiple sets of dates for each timezone and Current LocalDateTime calculated based on the timezone&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In fact table i have getting amount value with the timezone and&amp;nbsp; localtime for the timezone&amp;nbsp; for that country.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have to calculate Last 12 months Flag in Calendar Date table based on the Country selected from the Sales table in the report filter.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have added active relationship on CalendarDate - "Date" column with Sales - "Date" column&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and inactive relationship on "TimeZone" column&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Below is the table schema :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CalendarDate&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sales&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TimeZone&amp;nbsp; LocalTime&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TimeZone&amp;nbsp; &amp;nbsp; LocalTime&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Country&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1/1/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; GMT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4/10/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1/10/2019&amp;nbsp; &amp;nbsp; GMT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4/10/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UK&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;--------&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IST&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/10/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -------&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IST&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/10/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; INDIA&lt;/P&gt;&lt;P&gt;----&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks,&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Fri, 04 Oct 2019 17:41:42 GMT</pubDate>
    <dc:creator>Anonymous</dc:creator>
    <dc:date>2019-10-04T17:41:42Z</dc:date>
    <item>
      <title>User Relationship function is not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Relationship-function-is-not-working/m-p/810154#M5182</link>
      <description>&lt;P&gt;Hi,&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I have to findout localdate from the date table based on the timezone matched with the fact table. I am using below dax but its not working.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CurrentDay =&amp;nbsp;&lt;/SPAN&gt;&lt;SPAN&gt;CALCULATE (&lt;/SPAN&gt;&lt;SPAN&gt;VALUES(CalendarDate[LocalDateTime]), &lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;USERELATIONSHIP(&lt;/SPAN&gt;&lt;SPAN&gt;Sales[TimeZone],&lt;/SPAN&gt;&lt;SPAN&gt;CalendarDate[TimeZone]&lt;/SPAN&gt;&lt;SPAN&gt; )&lt;/SPAN&gt;&lt;SPAN&gt;)&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have the calendarDate table having multiple sets of dates for each timezone and Current LocalDateTime calculated based on the timezone&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;In fact table i have getting amount value with the timezone and&amp;nbsp; localtime for the timezone&amp;nbsp; for that country.&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have to calculate Last 12 months Flag in Calendar Date table based on the Country selected from the Sales table in the report filter.&amp;nbsp;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;I have added active relationship on CalendarDate - "Date" column with Sales - "Date" column&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;and inactive relationship on "TimeZone" column&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Below is the table schema :&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;CalendarDate&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Sales&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;TimeZone&amp;nbsp; LocalTime&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;Date&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; TimeZone&amp;nbsp; &amp;nbsp; LocalTime&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; Country&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;1/1/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; GMT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4/10/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;1/10/2019&amp;nbsp; &amp;nbsp; GMT&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 4/10/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; UK&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;--------&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;IST&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/10/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; -------&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; IST&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;5/10/2019&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; INDIA&lt;/P&gt;&lt;P&gt;----&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;Thanks,&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Fri, 04 Oct 2019 17:41:42 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Relationship-function-is-not-working/m-p/810154#M5182</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2019-10-04T17:41:42Z</dc:date>
    </item>
    <item>
      <title>Re: User Relationship function is not working</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Relationship-function-is-not-working/m-p/3980953#M154369</link>
      <description>&lt;P&gt;To achieve the required calculations using the inactive relationship in DAX, you need to activate the relationship within the calculation. Here’s how you can properly set up the calculation for the CurrentDay and subsequently use it to flag the last 12 months based on the country selected.&lt;/P&gt;
&lt;P&gt;Step 1: Correct Calculation of CurrentDay&lt;BR /&gt;The DAX expression you provided should work with USERELATIONSHIP, but you need to ensure it’s properly structured. Also, since the VALUES function returns a table, you might want to use SELECTEDVALUE or MIN/MAX if you expect a single value.&lt;/P&gt;
&lt;P&gt;CurrentDay = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;SELECTEDVALUE(CalendarDate[LocalDateTime]),&lt;BR /&gt;USERELATIONSHIP(Sales[TimeZone], CalendarDate[TimeZone])&lt;BR /&gt;)&lt;BR /&gt;Step 2: Flagging Last 12 Months&lt;BR /&gt;Next, you need to create the flag for the last 12 months in the CalendarDate table based on the country selected. Ensure that you are correctly using the CurrentDay calculated column.&lt;/P&gt;
&lt;P&gt;Adjusting the Date Column for the Last 12 Months&lt;BR /&gt;You’ll need a calculated column or measure to determine if the date falls within the last 12 months from the CurrentDay.&lt;/P&gt;
&lt;P&gt;Calculated Column for Last 12 Months Flag&lt;BR /&gt;First, ensure your CurrentDay calculation works and reflects the correct local date. Then, use this value to create a flag for the last 12 months.&lt;/P&gt;
&lt;P&gt;Step 3: Create the Last 12 Months Flag in CalendarDate&lt;BR /&gt;Create a calculated column in the CalendarDate table to flag dates within the last 12 months based on the local date:&lt;/P&gt;
&lt;P&gt;Last12MonthsFlag = &lt;BR /&gt;VAR CurrentLocalDate = &lt;BR /&gt;CALCULATE(&lt;BR /&gt;MAX(Sales[LocalTime]),&lt;BR /&gt;USERELATIONSHIP(Sales[TimeZone], CalendarDate[TimeZone])&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;IF(&lt;BR /&gt;CalendarDate[LocalDateTime] &amp;gt;= EDATE(CurrentLocalDate, -12) &amp;amp;&amp;amp; CalendarDate[LocalDateTime] &amp;lt;= CurrentLocalDate,&lt;BR /&gt;"Last 12 Months",&lt;BR /&gt;"Not Last 12 Months"&lt;BR /&gt;)&lt;BR /&gt;Step 4: Ensure Proper Relationships&lt;BR /&gt;Make sure your data model has the following relationships set correctly:&lt;/P&gt;
&lt;P&gt;Active relationship between CalendarDate[Date] and Sales[Date].&lt;BR /&gt;Inactive relationship between CalendarDate[TimeZone] and Sales[TimeZone].&lt;BR /&gt;Step 5: Use the Flag in Reports&lt;BR /&gt;Use the Last12MonthsFlag in your visual filters to show or hide data based on the flag:&lt;/P&gt;
&lt;P&gt;Add the Last12MonthsFlag to your visuals as a filter.&lt;BR /&gt;Set the filter to display only data where Last12MonthsFlag equals "Last 12 Months".&lt;/P&gt;</description>
      <pubDate>Sat, 08 Jun 2024 01:58:49 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/User-Relationship-function-is-not-working/m-p/3980953#M154369</guid>
      <dc:creator>technolog</dc:creator>
      <dc:date>2024-06-08T01:58:49Z</dc:date>
    </item>
  </channel>
</rss>

