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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Delphia
Advocate II
Advocate II

FILTER only positive values

Hi everybody,

I have a problem with filtering only positive values. I have the following formula (see below). 

When I use it in Matrix, it shows wrong Totals.

image.jpg

Target Capacity = [Target occupation ( % )]*[Capacity ( total )]
Target occupation ( % ) = MAX(Time_management[Target_Occupation])
Capacity ( total ) = SUM(Time_management[Capacity])
 

 

When I use the same formula but without IF statement I have the following picture (Totals also wrong):

skills»_wo_filter.jpg

 

The question is how to show correctly Availability but not taking into account negative values and receive correct totals?

 

Thank you in advance!

2 ACCEPTED SOLUTIONS
AlexisOlson
Super User
Super User

Suppose the lowest level of your hierarchy in your visual is Table1[Item]. Then you need to iterate over each of those items.

 

Availability ( hours + ) =
SUMX (
    VALUES ( Table1[Item] ),
    VAR __available = [Target Capacity] - [Planned Hours ( Total )]
    RETURN
        IF ( __available > 0, __available )
)

View solution in original post

You can use other columns from related tables. See the documentation.

 

It might work better to start with Skills and use Staff[Name] though.

 

Availability =
VAR Summary =
    SUMMARIZE (
        Skills,
        Staff[Name],
        Skills[Skill],
        Skills[Experience level],
        "@Hours", [Target Capacity] - [Planned Hours ( Total )]
    )
RETURN
    SUMX ( FILTER ( Summary, [@Hours] > 0 ), [@Hours] )

View solution in original post

15 REPLIES 15
AlexisOlson
Super User
Super User

Suppose the lowest level of your hierarchy in your visual is Table1[Item]. Then you need to iterate over each of those items.

 

Availability ( hours + ) =
SUMX (
    VALUES ( Table1[Item] ),
    VAR __available = [Target Capacity] - [Planned Hours ( Total )]
    RETURN
        IF ( __available > 0, __available )
)

Hm... Still have problem with Grand Totals per column... @AlexisOlson 

totals_col.jpg

 

My matrix parameters are the following:

hierarchy.jpg

 

Thank you!

 

 

You have additional complications if the same name can appear under multiple skills. The skill level may be another level of granularity to take into consideration.

 

For things to necessarily add up, you need to sum the total at the same level of granularity as the individual cells. This may be easier with a slightly different approach:

 

Availability =
VAR Summary =
    SUMMARIZE (
        Staff,
        Staff[Skill],
        Staff[Experience level],
        Staff[Name],
        "@Hours", [Target Capacity] - [Planned Hours ( Total )]
    )
RETURN
    SUMX ( FILTER ( Summary, [@Hours] > 0 ), [@Hours] )

It doesn't show correct values...summarize.jpg

 

The problem is that I don't have names in the table Skills_DB, only staffer_id. Names are in table Staffer.

id.jpg

If I apply your formula to matrix, it works with staffer_id. But I actualy need names...

My schema is the following:

schema.jpg

How about this?

 

Availability =
VAR Summary =
    SUMMARIZE (
        Staff,
        Staff[Name],
        Skills_DB[Skill],
        Skills_DB[Experience level],
        "@Hours", [Target Capacity] - [Planned Hours ( Total )]
    )
RETURN
    SUMX ( FILTER ( Summary, [@Hours] > 0 ), [@Hours] )

Unfortunately, no...

skills_av.jpg

I can't easily debug name errors without access to the file. I can't even tell if your table is Skills_DB or Skills since you have screenshots with both variations.

Sorry, it's the same table, I just renamed it. If I understand correctly the error, the problem is that in SUMMARIZE function in your formula the table that is used is Staff (the first parameter), but then you use columns from another table.

You can use other columns from related tables. See the documentation.

 

It might work better to start with Skills and use Staff[Name] though.

 

Availability =
VAR Summary =
    SUMMARIZE (
        Skills,
        Staff[Name],
        Skills[Skill],
        Skills[Experience level],
        "@Hours", [Target Capacity] - [Planned Hours ( Total )]
    )
RETURN
    SUMX ( FILTER ( Summary, [@Hours] > 0 ), [@Hours] )

One more qustion. If I want to apply specific coefficient to this measure, is it any way to do it inside calculation?


I need to multiply the Availability by Skills[Factor] that depends on:

1. Staff[Name] (or Skills[staffer_id])
2. Skills[Skill]

 

Thank you in advance!

I solved this, thank you once more time!

Thank you so much for your help!

It works! Thank you so much for your detailed explanation and help!

amitchandak
Super User
Super User

@Delphia , You have the force row total 

 

return

sumx(values(Table[kentico]), if(_available>0, _available, blank()))

 

 

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thank you. It helps to eliminate negative values but totals are still not correct...

image (1).jpg

As the result it should be:

Total for column Basic: 56+24=80,

Total for column Intermediate: 16 

Total for Kentico: 80+16=96

 

Thank you!

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors