Latest Enterprise DNA Initiatives

Dynamically Hide a Card

In Power BI, is there a way to conditionally hide a card (or multi-row card) based on field values?

I would like to hide the visual, if the field is zero or blank. The posts I found on community sound like maybe not, but there are a lot of proposed ‘PBI ideas’.

Thanks,
RK

@rit372002 There is a way to make it look like the card is hidden by giving the same color to cards as the background and then making use of the Conditional Formatting options under Data Labels & Category as follows:

Dynamically Hide Card.pbix (21.9 KB)

Let us know if you any questions.

Thanks.

3 Likes

Hello @rit372002,
Yes, you can conditionally hide a card in Power Bi based on field values

You need 2 DAX measures that should be formatted as TEXT:

  1. to conditionally format the font
Font Color Switch = 
    var a = SELECTEDVALUE('Table'[Value])
    RETURN
    SWITCH(
        true(),
        a=0,"#FFFFFF00",
        "252423")
  1. to conditionally format the background
Background Color Switch = 
var a = SELECTEDVALUE('Table'[Value])
RETURN
SWITCH(
    true(),
    a=0,"#FFFFFF00",
    "#A0D1FF")

The two measures will bring the HEX code #FFFFFF which corresponds to white, but what makes it transparent is the 00 at the end. If you use DAX you can add transparency directly in the code. :wink:

Then you have to go to FORMAT/ Data label / click on FX and choose your measure
and FORMAT/ Background/ click on FX and choose your measure

I created a sample ex for you,
Highlight invisible card.pbix (16.3 KB)

Best regards,
Alex

4 Likes

@alexbadiu @MudassirAli

Thanks both of you!

What a brilliant solutions!

I will mark @alexbadiu as solution as it works perfect for my situation. Very very elegant :slight_smile:

3 Likes