Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
ArchStanton
Impactful Individual
Impactful Individual

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

17 REPLIES 17
danextian
Super User
Super User

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

 

danextian_2-1768824067202.png

 

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.

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?

 

ArchStanton_0-1768985858402.png

 

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.

vtejrama_0-1769146587022.png

 

 

Best Regards,
Tejaswi.
Community Support

Thanks again for your advice, i really appreciate all of your help.

 

Unless you say otherwise I don't think its possible to do what I want?
I want the months of the Max and Min markers in the Sparkline to be shown in the tooltip. The sparklines represent the FY Apr - Mar.

ArchStanton_0-1769182391571.png

 

Your Max & Min tooltip does work, it seems like we're not a million miles from achieving my aim?

 

Hello @ArchStanton ,

The main issue was that the tooltip was only evaluating the single hovered point instead of the full month range shown in the sparkline. To fix this, I rebuilt the example using a proper Calendar table linked to the cases data by date, and added a fiscal month number (Apr–Mar) so the months sort correctly. The tooltip measures then use ALLSELECTED to look across all months in the sparkline context, and TOPN to determine which month has the highest and lowest values, returning the month names instead of just the numbers.

 

I added the measures to a report tooltip page and linked it to the matrix. Now, when you hover over a row, the tooltip shows the actual months where the sparkline reaches its maximum and minimum, not just the values. Because the logic evaluates over the same month context as the sparkline, it works consistently even within the limited filter context of a tooltip.

 

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

vtejrama_1-1769506926215.png

Best Regards,
Tejaswi.
Community Support

 

Hi @ArchStanton ,

 

I wanted to follow up and see if you had a chance to review the information shared. If you have any further questions or need additional assistance, feel free to reach out.

Thank you.

 

Hi, I've been away and not had a chance to look at your latest advice, I will try and get back to by the end of tomorrow at latest - thanks again for helping!

Hi @ArchStanton ,

 

I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions.

Thank you.

Hi,

 

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

ArchStanton_1-1768840595969.png

 

 

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?

v-tejrama
Community Support
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






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.

 

ArchStanton_0-1768819516637.png

 

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, I am using the latest version of PowerBI (2.149.1429.0) so I'm not sure why I'm getting these error messages? I'm based in the UK so maybe there's a delay here?

Anyway, I'm not far from finding a solution to this thanks to the help of another superuser (see thread below). The problem I'm having is that I have NULLs in my data so when counting the Min value it's picking up NULLs up instead of the MinCount.

DataVitalizer
Super User
Super User

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

I tried your code and got the following error:

ArchStanton_0-1768581480684.png

 

krishnakanth240
Impactful Individual
Impactful Individual

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!

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

ArchStanton_1-1768581925209.png

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.