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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
Anonymous
Not applicable

Dinamic Tooltip Title

Hello 
I have created the Dax script below which changes the title of a reporting tooltip dynamically, however, if I have a category as "blank", there is no title being displayed at the moment.
Is it possible to change the script below to show the information "No record available".
 
ToolTip_Tile =
VAR SelectedMainCategory =
IF ( HASONEFILTER ( Dataset[ Cateogry] ), TRUE, FALSE )
VAR SelectedLocation =
IF ( HASONEFILTER ( Dataset[Location] ), TRUE, FALSE )
VAR MainCategory =
SELECTEDVALUE ( Dataset[ Cateogry], "Select Category" )
VAR Location =
SELECTEDVALUE ( Dataset[Location], "Select Location" )
RETURN
IF ( SelectedMainCategory, MainCategory, IF ( SelectedLocation, Location))
1 ACCEPTED SOLUTION
Anonymous
Not applicable

[ToolTip Tile] =
    SWITCH ( TRUE (),
    
        HASONEFILTER ( Dataset[Category] ),
        	SELECTEDVALUE (
        		Dataset[Cateogry],
        		"Select Category" 
        	),
        	
        HASONEFILTER ( Dataset[Location] ),
        	SELECTEDVALUE (
        		Dataset[Location],
        		"Select Location"
        	),
        	
        "No record available"
    )

 

If you want to save time, then you want to carry out calculation inside SWITCH, not outside. SWITCH will often (not always) perform only the needed calculations whereas if you take out the formulas and put them in variables outside SWITCH, all of them will get calculated (unnecessarily most of the time).

 

Best

D

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

[ToolTip Tile] =
    SWITCH ( TRUE (),
    
        HASONEFILTER ( Dataset[Category] ),
        	SELECTEDVALUE (
        		Dataset[Cateogry],
        		"Select Category" 
        	),
        	
        HASONEFILTER ( Dataset[Location] ),
        	SELECTEDVALUE (
        		Dataset[Location],
        		"Select Location"
        	),
        	
        "No record available"
    )

 

If you want to save time, then you want to carry out calculation inside SWITCH, not outside. SWITCH will often (not always) perform only the needed calculations whereas if you take out the formulas and put them in variables outside SWITCH, all of them will get calculated (unnecessarily most of the time).

 

Best

D

AntrikshSharma
Super User
Super User

You can remove that IF condition from HASONEFILTER because it already returns TRUE if the column has one filter else it returns FALSE. You can try this construct, let me know if it doesn't work for you.

ToolTip_Tile =
VAR SelectedMainCategory =
    HASONEFILTER ( Dataset[ Cateogry] )
VAR SelectedLocation =
    HASONEFILTER ( Dataset[Location] )
VAR MainCategory =
    SELECTEDVALUE ( Dataset[ Cateogry], "Select Category" )
VAR Location =
    SELECTEDVALUE ( Dataset[Location], "Select Location" )
RETURN
    SWITCH (
        TRUE (),
        SelectedMainCategory, MainCategory,
        SelectedLocation, Location,
        "No record available"
    )

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.