<?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: USE Relationship with Switch in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4315209#M171349</link>
    <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="797683" data-lia-user-login="David_Verdon" class="lia-mention lia-mention-user"&gt;David_Verdon&lt;/a&gt;&amp;nbsp;, Try using this then&lt;/P&gt;
&lt;P&gt;DAX&lt;BR /&gt;Sales Value =&lt;BR /&gt;VAR Status_ = SELECTEDVALUE(ProjectDetails[ProjectStatus])&lt;BR /&gt;VAR Rev = [Revenue Actual]&lt;BR /&gt;VAR Fee = SUM(ProjectDetails[FeeEstimate])&lt;BR /&gt;VAR Result =&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;Status_ = "Closed Project",&lt;BR /&gt;CALCULATE(&lt;BR /&gt;Rev,&lt;BR /&gt;USERELATIONSHIP(ProjectDetails[ClosedDate], 'Date'[Date])&lt;BR /&gt;),&lt;BR /&gt;Status_ = "Live Project",&lt;BR /&gt;CALCULATE(&lt;BR /&gt;Fee - Rev,&lt;BR /&gt;USERELATIONSHIP(CMap_ProjectDetails_Live[WonDate], 'Date'[Date]),&lt;BR /&gt;REMOVEFILTERS('Date'),&lt;BR /&gt;USERELATIONSHIP(ProjectDetails[ClosedDate], 'Date'[Date])&lt;BR /&gt;),&lt;BR /&gt;BLANK()&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;Result&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The USERELATIONSHIP function for ClosedDate is explicitly deactivated for the "Live Project" calculation.&lt;/P&gt;</description>
    <pubDate>Thu, 05 Dec 2024 12:04:52 GMT</pubDate>
    <dc:creator>bhanu_gautam</dc:creator>
    <dc:date>2024-12-05T12:04:52Z</dc:date>
    <item>
      <title>USE Relationship with Switch</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4315064#M171340</link>
      <description>&lt;P&gt;I'm working on a DAX measure to calculate Sales Value based on project status. The measure should use different date relationships for "Closed Project" and "Live Project" statuses. Here's the measure I'm using:&lt;/P&gt;&lt;P&gt;Sales Value =&lt;BR /&gt;VAR Status_ = SELECTEDVALUE(ProjectDetails[ProjectStatus])&lt;BR /&gt;VAR Rev = [Revenue Actual]&lt;BR /&gt;VAR Fee = SUM(ProjectDetails[FeeEstimate])&lt;BR /&gt;VAR Result =&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;Status_ = "Closed Project",&lt;BR /&gt;CALCULATE(Rev, USERELATIONSHIP(ProjectDetailsClosedDate], 'Date'[Date])),&lt;BR /&gt;Status_ = "Live Project",&lt;BR /&gt;CALCULATE(Fee - Rev, USERELATIONSHIP(CMap_ProjectDetails_Live[WonDate], 'Date'[Date])),&lt;BR /&gt;BLANK()&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;Result&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;BR /&gt;The goal is to:&lt;/P&gt;&lt;P&gt;Use the ClosedDate relationship for "Closed Project" status.&lt;BR /&gt;Use the WonDate relationship for "Live Project" status.&lt;BR /&gt;However, when I add a slicer from the Date table, only "Closed Project" data is shown. I suspect the active relationship with ClosedDate is overriding the measure for "Live Project."&lt;/P&gt;&lt;P&gt;I've tried using REMOVEFILTERS('Date') to clear existing filters before applying USERELATIONSHIP, but it hasn't resolved the issue. Any suggestions on how to ensure the slicer works correctly for both statuses?&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 10:00:59 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4315064#M171340</guid>
      <dc:creator>David_Verdon</dc:creator>
      <dc:date>2024-12-05T10:00:59Z</dc:date>
    </item>
    <item>
      <title>Re: USE Relationship with Switch</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4315105#M171343</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="797683" data-lia-user-login="David_Verdon" class="lia-mention lia-mention-user"&gt;David_Verdon&lt;/a&gt;&amp;nbsp;, Try using below DAX&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Sales Value =&lt;BR /&gt;VAR Status_ = SELECTEDVALUE(ProjectDetails[ProjectStatus])&lt;BR /&gt;VAR Rev = [Revenue Actual]&lt;BR /&gt;VAR Fee = SUM(ProjectDetails[FeeEstimate])&lt;BR /&gt;VAR Result =&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;Status_ = "Closed Project",&lt;BR /&gt;CALCULATE(&lt;BR /&gt;Rev,&lt;BR /&gt;TREATAS(VALUES('Date'[Date]), ProjectDetails[ClosedDate])&lt;BR /&gt;),&lt;BR /&gt;Status_ = "Live Project",&lt;BR /&gt;CALCULATE(&lt;BR /&gt;Fee - Rev,&lt;BR /&gt;TREATAS(VALUES('Date'[Date]), CMap_ProjectDetails_Live[WonDate])&lt;BR /&gt;),&lt;BR /&gt;BLANK()&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;Result&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 10:39:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4315105#M171343</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2024-12-05T10:39:30Z</dc:date>
    </item>
    <item>
      <title>Re: USE Relationship with Switch</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4315176#M171348</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="625922" data-lia-user-login="bhanu_gautam" class="lia-mention lia-mention-user"&gt;bhanu_gautam&lt;/a&gt;&amp;nbsp;thank you&lt;BR /&gt;&lt;BR /&gt;i tried using the Dax code as suggested but i get the same result&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Measure shows values for both project types as expected, however as soon as i introduce a selection from the date table/slicer it only displays closed projects - there is an active realtionship between closed date and Date and an inactive relationship between won date and date&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thnaks&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;David&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 11:22:31 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4315176#M171348</guid>
      <dc:creator>David_Verdon</dc:creator>
      <dc:date>2024-12-05T11:22:31Z</dc:date>
    </item>
    <item>
      <title>Re: USE Relationship with Switch</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4315209#M171349</link>
      <description>&lt;P&gt;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="797683" data-lia-user-login="David_Verdon" class="lia-mention lia-mention-user"&gt;David_Verdon&lt;/a&gt;&amp;nbsp;, Try using this then&lt;/P&gt;
&lt;P&gt;DAX&lt;BR /&gt;Sales Value =&lt;BR /&gt;VAR Status_ = SELECTEDVALUE(ProjectDetails[ProjectStatus])&lt;BR /&gt;VAR Rev = [Revenue Actual]&lt;BR /&gt;VAR Fee = SUM(ProjectDetails[FeeEstimate])&lt;BR /&gt;VAR Result =&lt;BR /&gt;SWITCH(&lt;BR /&gt;TRUE(),&lt;BR /&gt;Status_ = "Closed Project",&lt;BR /&gt;CALCULATE(&lt;BR /&gt;Rev,&lt;BR /&gt;USERELATIONSHIP(ProjectDetails[ClosedDate], 'Date'[Date])&lt;BR /&gt;),&lt;BR /&gt;Status_ = "Live Project",&lt;BR /&gt;CALCULATE(&lt;BR /&gt;Fee - Rev,&lt;BR /&gt;USERELATIONSHIP(CMap_ProjectDetails_Live[WonDate], 'Date'[Date]),&lt;BR /&gt;REMOVEFILTERS('Date'),&lt;BR /&gt;USERELATIONSHIP(ProjectDetails[ClosedDate], 'Date'[Date])&lt;BR /&gt;),&lt;BR /&gt;BLANK()&lt;BR /&gt;)&lt;BR /&gt;RETURN&lt;BR /&gt;Result&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;The USERELATIONSHIP function for ClosedDate is explicitly deactivated for the "Live Project" calculation.&lt;/P&gt;</description>
      <pubDate>Thu, 05 Dec 2024 12:04:52 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4315209#M171349</guid>
      <dc:creator>bhanu_gautam</dc:creator>
      <dc:date>2024-12-05T12:04:52Z</dc:date>
    </item>
    <item>
      <title>Re: USE Relationship with Switch</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4316459#M171390</link>
      <description>&lt;P&gt;Hi&amp;nbsp;&lt;a href="javascript:void(0)" data-lia-user-mentions="" data-lia-user-uid="797683" data-lia-user-login="David_Verdon" class="lia-mention lia-mention-user"&gt;David_Verdon&lt;/a&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;&lt;SPAN&gt;Did bhanu_gautam&amp;nbsp;'s method solve your problem? If so, could you please accept it as a solution? This will help more users who are facing the same or similar difficulties. Thank you!&lt;/SPAN&gt;&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;If your problem persists, could you please provide example data and expected results based on the example data so we can better help you?&amp;nbsp;&lt;A href="https://community.fabric.microsoft.com/t5/Power-BI-Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-p/963216" target="_blank"&gt;How to provide sample data in the Power BI Forum - Microsoft Fabric Community&lt;/A&gt;&amp;nbsp;Or show them as screenshots or pbix. Please remove any sensitive data in advance. If uploading pbix files please do not log into your account.&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;Best Regards,&lt;BR /&gt;Yulia Xu&lt;/P&gt;</description>
      <pubDate>Fri, 06 Dec 2024 06:15:23 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4316459#M171390</guid>
      <dc:creator>Anonymous</dc:creator>
      <dc:date>2024-12-06T06:15:23Z</dc:date>
    </item>
    <item>
      <title>Re: USE Relationship with Switch</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4317337#M171417</link>
      <description>&lt;P&gt;The problem is that variables in DAX aren't really variable, they are constants. Once they are evaluated they are never evaluated again, so trying to reevaluate them in a different context won't work. Try&lt;/P&gt;
&lt;LI-CODE lang="markup"&gt;Sales Value =
VAR Status_ =
    SELECTEDVALUE ( ProjectDetails[ProjectStatus] )
VAR Result =
    SWITCH (
        TRUE (),
        Status_ = "Closed Project",
            CALCULATE (
                [Revenue Actual],
                USERELATIONSHIP ( ProjectDetails[ClosedDate], 'Date'[Date] )
            ),
        Status_ = "Live Project",
            CALCULATE (
                SUM ( ProjectDetails[FeeEstimate] ) - [Revenue Actual],
                USERELATIONSHIP ( CMap_ProjectDetails_Live[WonDate], 'Date'[Date] )
            ),
        BLANK ()
    )
RETURN
    Result
&lt;/LI-CODE&gt;</description>
      <pubDate>Fri, 06 Dec 2024 15:57:24 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/USE-Relationship-with-Switch/m-p/4317337#M171417</guid>
      <dc:creator>johnt75</dc:creator>
      <dc:date>2024-12-06T15:57:24Z</dc:date>
    </item>
  </channel>
</rss>

