Forum Discussion

ArchStanton's avatar
ArchStanton
Power Participant
6 months ago
Solved

Conditional Formatting within Tooltip

Hi

I have a measure that shows the Max and Min value in a Matrix - it works no problem.

 

However, I cannot get this to work as a tooltip - is it even possible?

 

MinMaxMeasure =
VAR ValuesDisplayed =
    CALCULATETABLE (
        ADDCOLUMNS (
            SUMMARIZE ( 'Cases', 'Cases'[PrimaryTopic2] ),
            "Count", [Primary Topics]
        ),
        ALLSELECTED ()
    )
VAR MinVal =
    MINX ( ValuesDisplayed, [Count] )
VAR MaxVal =
    MAXX ( ValuesDisplayed, [Count] )
VAR CurrentValue = [Primary Topics]
VAR Result =
    SWITCH ( TRUE (), CurrentValue = MinVal, 1, CurrentValue = MaxVal, 2 )
RETURN
    Result

 

Thanks

  • Hi,

    Thanks for the help with this, its much appreciated.

     

    Unfortunately, this isn't the behaviour I'm looking for as a solution, I need the Max & Min month name to be showing in the tooltip, preferably in its own column, your solution doesn't make it immediately obvious what months out of a possible 12 are the Max and Min.

    I will close this ticket and re-open a new one.

    It maybe the fact that what I'm asking for is not even possible so it will be good to re-issue a new version of this ticket to see if that even possible.

    Once again, thanks for all your help!

25 Replies

  • Hi ArchStanton 

     

    Can you please share the screenshot what exactly you are viewing when you add the above measure into table visual for the tooltip. Can you explain how the output should be.  Thank you!

    • ArchStanton's avatar
      ArchStanton
      Power Participant

      So the tooltip should show red (Max) and Blue (Min) for the monthly values 
      Jan = MIN

      Aug Max

       

      As you can see, it works fine in the Matrix but its in the tooltip that I want to be able to see the Max & Min

       

  • Hi ArchStanton 

    You need to force the measure to always consider the full set you want, ignoring the current tooltip row context:

    MinMaxMeasureTooltip =
    VAR ValuesDisplayed =
    CALCULATETABLE (
    ADDCOLUMNS (
    SUMMARIZE ( 'Cases', 'Cases'[PrimaryTopic2] ),
    "Count", [Primary Topics]
    ),
    ALLSELECTED('Cases'[PrimaryTopic2]) // make sure all rows are included
    )
    VAR MinVal = MINX(ValuesDisplayed, [Count])
    VAR MaxVal = MAXX(ValuesDisplayed, [Count])
    VAR CurrentValue = SELECTEDVALUE('Cases'[PrimaryTopic2])
    VAR Result =
    SWITCH(
    TRUE(),
    CurrentValue = MinVal, "Min",
    CurrentValue = MaxVal, "Max",
    BLANK()
    )
    RETURN
    Result

     

    Did it work? 👍 A kudos would be appreciated
    🟨 Mark it as a solution to help spread knowledge 💡

    đźź© Let's connect on LinkedIn

    • ArchStanton's avatar
      ArchStanton
      Power Participant

      I tried your code and got the following error:

       

  • v-tejrama's avatar
    v-tejrama
    Community Support

    Hi ArchStanton ,

    Thanks for reaching out to the Microsoft fabric community forum.

    This is expected behavior in Power BI and works as designed. A matrix visual and a tooltip page are evaluated under different filter contexts. The matrix evaluates the measure across all visible rows, allowing Min and Max logic to compare values across the entire set of categories. In contrast, a tooltip page is evaluated only for the specific data point being hovered over, so the filter context contains just that value.

     

    Since Min and Max calculations need multiple rows to compare, the measure returns a blank result in this context, which Power BI displays as two dashes in a card visual. This isn't a syntax issue or a problem with the measure, but rather how tooltip evaluation functions. To make Min or Max logic work the same way in a tooltip, you need to expand the filter context within the measure to include all relevant rows.


    Please find the attached PBIX and Screenshort file for your reference.

     

    Best Regards,
    Tejaswi.
    Community Support






    • ArchStanton's avatar
      ArchStanton
      Power Participant

      Thanks for this, I tried opening the pbix but had errors - it looks like I'm back using a November version of PowerBI (I had a new work laptop recently). Once IT update me I'll have a look at what you attached and get back to you.

       

       

      • v-tejrama's avatar
        v-tejrama
        Community Support

        Hi ArchStanton ,

         

        Understood, that makes sense considering the laptop change.

        Once IT has completed the Power BI update and you’re able to access the PBIX file, please let me know if you have any questions. In the meantime, if anything else comes up, please feel free to keep me informed.

        Best regards,
        Tejaswi.

  • Hi ArchStanton 

    Try this pattern and also ensure to use in the visual the same dimensions specified in the measure.

    MinMaxMeasure = 
    VAR valuesDisplayed =
        ADDCOLUMNS ( SUMMARIZE ( ALLSELECTED ( Data ), Data[Date] ), "count", [Total Transactions] )
    VAR MinVal =
        MINX ( valuesDisplayed, [count] )
    VAR MaxVal =
        MAXX ( valuesDisplayed, [count] )
    VAR Currentvalue = [Total Transactions]
    VAR Result =
        SWITCH ( TRUE (), CurrentValue = MinVal, 1, CurrentValue = MaxVal, 2 )
    RETURN
        Result
    

     

     

     

    • ArchStanton's avatar
      ArchStanton
      Power Participant

      Hi,

       

      Unfortunately your code just gives me a 1 but not a 2 - the 1 is alongside missing Primary Topics.

       

       

      MinMaxMeasure1 = 
      VAR valuesDisplayed =
          ADDCOLUMNS ( SUMMARIZE ( ALLSELECTED ( 'Cases'),'Cases'[Created On]), "count", [Primary Topics] )
      VAR MinVal =
          MINX ( valuesDisplayed, [count] )
      VAR MaxVal =
          MAXX ( valuesDisplayed, [count] )
      VAR Currentvalue = [Primary Topics]
      VAR Result =
          SWITCH ( TRUE (), CurrentValue = MinVal, 1, CurrentValue = MaxVal, 2 )
      RETURN
          Result

      The problem I have is that not every Primary Topic is populated (I have lots of NULLs), whereas your Date field is continous.

      Any ideas?

    • ArchStanton's avatar
      ArchStanton
      Power Participant

      Hi,

      I have Blank Primary Topics in my data so the MinValue is picking these up. I've tried to isolate Blanks as zero so I can exclude them from the code, I've done this - is it possible to select the next smalles MinValue?

       

       

      • v-tejrama's avatar
        v-tejrama
        Community Support

        Hello again ArchStanton ,

         

        To address this scenario, it's important to recognize that tooltip visuals operate within a much narrower filter context compared to standard visuals like a matrix. When hovering over a value, the tooltip only considers that specific category, so any logic intended to compare values across categories will not work unless the context is deliberately broadened.

         

        The recommended approach is to use a measure that evaluates all visible categories by applying ALLSELECTED to the category field, then calculating the minimum and maximum from that set while excluding blanks. After creating this measure, add it to a dedicated tooltip page and assign that page to the matrix.

         

        Please find the attached PBIX and Screenshort file for your reference.

         

         

        Best Regards,
        Tejaswi.
        Community Support