<?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 Switch and comparing values of the same column in DAX Commands and Tips</title>
    <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-and-comparing-values-of-the-same-column/m-p/3782293#M147757</link>
    <description>&lt;P&gt;Hello Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My dataset Resume : Player# | Label| Value&lt;BR /&gt;Label can be "TOPS", "Competition", "Management", "Training"&lt;/P&gt;&lt;P&gt;Value is the value of the Label&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to show a colour based on the value and the Label&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ColumnColour = 
VAR ValueCompet = CALCULATE(MAX('Resume'[Value]), 'Resume'[Label] = "Competition")
VAR ValueTrain = CALCULATE(MAX('Resume'[Value]), 'Resume'[Label] = "Training")
VAR RLabel = 'Resume'[Label]
VAR RValue = 'Resume'[Value]
RETURN
    SWITCH(
        TRUE(),
        RLabel = "Management", 
            SWITCH(
                TRUE(),
                RValue &amp;gt;= 150, "Green",
                RValue &amp;gt;= 90, "Yellow",
                TRUE(), "Red"
            ),
        RLabel = "TOPS"
           SWITCH(
                TRUE(),
                ValueTrain &amp;lt; ValueCompet, "Green",
                ValueTrain = ValueCompet, "Yellow",
                TRUE(), "Red"
            )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue lies with the last label "TOPS", where it consistently displays "Yellow" for all players. When the label is "TOPS", it only considers the value of "TOPS" instead of taking into account the comparison between `ValueEntr` and `ValueCompet`.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;After several attempts, I focused solely on the condition where Label equals TOP.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ColumnColour = 
IF(Resume[Label] = "TOPS", CALCULATE(MAX(Resume[Value]), FILTER(Resume, Resume[Label] = "Training")))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the result is blank.&lt;/P&gt;&lt;P&gt;The idea is how to display the value of "Training" where Label = TOPS. This is the root problem that's why the comparison doesn't work.&lt;/P&gt;&lt;P&gt;How can this be rectified?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Thu, 21 Mar 2024 14:37:07 GMT</pubDate>
    <dc:creator>LizK75</dc:creator>
    <dc:date>2024-03-21T14:37:07Z</dc:date>
    <item>
      <title>Switch and comparing values of the same column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-and-comparing-values-of-the-same-column/m-p/3782293#M147757</link>
      <description>&lt;P&gt;Hello Community,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;My dataset Resume : Player# | Label| Value&lt;BR /&gt;Label can be "TOPS", "Competition", "Management", "Training"&lt;/P&gt;&lt;P&gt;Value is the value of the Label&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I want to show a colour based on the value and the Label&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ColumnColour = 
VAR ValueCompet = CALCULATE(MAX('Resume'[Value]), 'Resume'[Label] = "Competition")
VAR ValueTrain = CALCULATE(MAX('Resume'[Value]), 'Resume'[Label] = "Training")
VAR RLabel = 'Resume'[Label]
VAR RValue = 'Resume'[Value]
RETURN
    SWITCH(
        TRUE(),
        RLabel = "Management", 
            SWITCH(
                TRUE(),
                RValue &amp;gt;= 150, "Green",
                RValue &amp;gt;= 90, "Yellow",
                TRUE(), "Red"
            ),
        RLabel = "TOPS"
           SWITCH(
                TRUE(),
                ValueTrain &amp;lt; ValueCompet, "Green",
                ValueTrain = ValueCompet, "Yellow",
                TRUE(), "Red"
            )
    )&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The issue lies with the last label "TOPS", where it consistently displays "Yellow" for all players. When the label is "TOPS", it only considers the value of "TOPS" instead of taking into account the comparison between `ValueEntr` and `ValueCompet`.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;After several attempts, I focused solely on the condition where Label equals TOP.&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="python"&gt;ColumnColour = 
IF(Resume[Label] = "TOPS", CALCULATE(MAX(Resume[Value]), FILTER(Resume, Resume[Label] = "Training")))&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;and the result is blank.&lt;/P&gt;&lt;P&gt;The idea is how to display the value of "Training" where Label = TOPS. This is the root problem that's why the comparison doesn't work.&lt;/P&gt;&lt;P&gt;How can this be rectified?&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thank you&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 14:37:07 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-and-comparing-values-of-the-same-column/m-p/3782293#M147757</guid>
      <dc:creator>LizK75</dc:creator>
      <dc:date>2024-03-21T14:37:07Z</dc:date>
    </item>
    <item>
      <title>Re: Switch and comparing values of the same column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-and-comparing-values-of-the-same-column/m-p/3783842#M147796</link>
      <description>&lt;P&gt;HI,&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Just add allexcept after your max calculations&lt;/P&gt;&lt;P&gt;&lt;img /&gt;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 18:13:30 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-and-comparing-values-of-the-same-column/m-p/3783842#M147796</guid>
      <dc:creator>JamesFR06</dc:creator>
      <dc:date>2024-03-21T18:13:30Z</dc:date>
    </item>
    <item>
      <title>Re: Switch and comparing values of the same column</title>
      <link>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-and-comparing-values-of-the-same-column/m-p/3783899#M147800</link>
      <description>&lt;P&gt;You are my Savior JamesFR06 Thank you so much&lt;/P&gt;&lt;P&gt;Merci beaucoup&amp;nbsp;&lt;span class="lia-unicode-emoji" title=":smiling_face_with_heart_eyes:"&gt;😍&lt;/span&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 21 Mar 2024 19:07:33 GMT</pubDate>
      <guid>https://community.fabric.microsoft.com/t5/DAX-Commands-and-Tips/Switch-and-comparing-values-of-the-same-column/m-p/3783899#M147800</guid>
      <dc:creator>LizK75</dc:creator>
      <dc:date>2024-03-21T19:07:33Z</dc:date>
    </item>
  </channel>
</rss>

