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

Power BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.

Reply
EugenioProlog
Helper I
Helper I

How do I Hide columns based on metric?

I have this Cohort on a matrix table that has Columns that vary according to a column on one of my tables. I want it to display only values that are not null. Is there a way to do that?

EugenioProlog_1-1750687309562.png

 


I'm trying something like this: 
IsLifetimeValid =
VAR CurrentLifetime = SELECTEDVALUE(Lifetime[Lifetime])
RETURN
IF(
NOT(ISBLANK(CurrentLifetime)) && CurrentLifetime <= [Maximo Lifetime],
TRUE,
FALSE
)

But it returns true to all the values, not just the ones that are smaller or equal to 17.

 

Here is the attachment to my pbix file.
https://drive.google.com/file/d/1frnBF0q_iSchNtfZoQGGpthfLihic9gy/view?usp=sharing

1 ACCEPTED SOLUTION
Demert
Resolver II
Resolver II

Hi @EugenioProlog ,

 

You can simply filter out the blanks in your filter pane by doing this:

Demert_0-1750688140516.png

This will not work for Cohort % because you always return 0 in the measure.

 

To fix this i suggest the following code 

Cohort % = 
VAR Numerador = 
    CALCULATE(
        [Subscriptions], 
        FILTER(
            client_base,
            client_base[lifetime_months] >= SELECTEDVALUE(Lifetime[Lifetime])
        )
    )
VAR Denominador = [Subscriptions]

RETURN 
if (ISBLANK(Numerador),BLANK(),
   0+ DIVIDE(Numerador, Denominador, 0) ) // Retorna 0 se o denominador for 0)

And then also filter out the blanks for this measure out in your filter pane.

View solution in original post

2 REPLIES 2
MFelix
Super User
Super User

Hi @EugenioProlog ,

 

You issue is the fact that you are using a COALESCE on your metric:

MFelix_0-1750688005316.png

This forces the value within the if to return 0 not at the metric itself but that the aggregated level of the calculation

MFelix_1-1750688128824.png

I assume you want to have the information only at the month year level try to add a is inscope to your calculation:

MFelix_2-1750688316490.png

 

See file attach.

Cohort = 
VAR MaxLifetime = 
    CALCULATE(
        MAX(client_base[lifetime_months]),
        ALLEXCEPT(client_base, dim__calendar[dsc_mesano])
    )
RETURN
    IF(
        SELECTEDVALUE(Lifetime[Lifetime]) <= MaxLifetime && ISINSCOPE(dim__calendar[dsc_mesano]),
        COALESCE(
            CALCULATE(
                [Subscriptions],
                FILTER(
                    client_base,
                    client_base[lifetime_months] >= SELECTEDVALUE(Lifetime[Lifetime])
                )
            ),
            0
        )
    )

 


Regards

Miguel Félix


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

Proud to be a Super User!

Check out my blog: Power BI em Português



Demert
Resolver II
Resolver II

Hi @EugenioProlog ,

 

You can simply filter out the blanks in your filter pane by doing this:

Demert_0-1750688140516.png

This will not work for Cohort % because you always return 0 in the measure.

 

To fix this i suggest the following code 

Cohort % = 
VAR Numerador = 
    CALCULATE(
        [Subscriptions], 
        FILTER(
            client_base,
            client_base[lifetime_months] >= SELECTEDVALUE(Lifetime[Lifetime])
        )
    )
VAR Denominador = [Subscriptions]

RETURN 
if (ISBLANK(Numerador),BLANK(),
   0+ DIVIDE(Numerador, Denominador, 0) ) // Retorna 0 se o denominador for 0)

And then also filter out the blanks for this measure out in your filter pane.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.