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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Ivancito111
Resolver I
Resolver I

Remove 0's in a row sum

Good afternoon dear, I have a doubt a little complicated to explain, I will try to do the best I can and any kind of information is of interest to me.

In my company they have credit applications, what happens is that they have an intake, interest and payments, which can be all in one installment or 300, the value is very changeable.

Within the data I have the company, the credit id, the bank, the type (take, interest, payment), the period, credit, debit and the balance (credit-debit).

 

N°companyID_CreditBankTypeperiodCreditDebitBalance

1dogCLP - 1Estadotake2021061000 1000
2catCLP - 1Chiletake2021061000 1000
3rabbitUF -1BBAtake2021061000 1000
4flyUF -1Estadotake2021061000 1000
5dogCLP - 1Estadointerest202107100 100
6catCLP - 1Chileinterest202107100 100
7rabbitUF -1BBAinterest202107100 100
8flyUF -1Estadointerest202107100 100
9dogCLP - 1Estadopayment202108 -300-300
10catCLP - 1Chilepayment202108 -300-300
11rabbitUF -1BBApayment202108 -300-300
12flyUF -1Estadopayment202108 -300-300
13dogCLP - 1Estadotake2021091000 1000
14catCLP - 1Chileinterest202109300 300
15rabbitUF -1BBApayment202109 -400-400
16flyUF -1Estadopayment202109 -400-400
17dogCLP - 1Estadointerest202110300 300
18catCLP - 1Chileinterest202110300 300
19rabbitUF -1BBApayment202110 -400-400
20flyUF -1Estadopayment202110 -400-400

 

What they want to see is a matrix that shows all the credit data, how much has been paid, how much interest has been generated and how much the loan was taken out.

 

Ivancito111_0-1636380470042.png

 

The problem is that doing it this way shows me the credits that are already paid (sum of balance = 0), but if I add a filter of balance != 0 it doesn't work because obviously there is no row where the balance is 0 in the data.

 

After some research I found an idea to create a summary table where the sum is done and add this sum in the table filter and make it non-zero, which would eliminate the problem.

 

Ivancito111_2-1636380692412.png

 

I add the sum filter

 

Ivancito111_3-1636380725761.png

But doing this does not allow me to filter by credit period, as they need to see a date before the date they chose, if they choose a 2108 period, they want to see the 2108, 2107 and 2106 period, making doing it this way does not work for me.

 

If anyone knows of a way to do the same I remain attentive to comments.
Thank you very much for reading my problem.
Regards,

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Ivancito111 

I think you can add some filter in your Filter measure to achieve your goal.

New code:

M_Filter = 
VAR _SelectPeriod =
    IF (
        ISFILTERED ( Period[Period] ),
        SELECTEDVALUE ( Period[Period] ),
        MAX ( Period[Period] )
    )
VAR _SumbyCompany =
    CALCULATE (
        SUM ( 'Table'[Balance] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Company] = MAX ( 'Table'[Company] )
                && 'Table'[ID_Credit] = MAX ( 'Table'[ID_Credit] )
                && 'Table'[Bank] = MAX ( 'Table'[Bank] )
                && 'Table'[Period] <= _SelectPeriod
        )
    )
RETURN
    _SumbyCompany

You see in my new Table I add UF-2 in rabbit as well, UF-1 will return 0 and UF-2 doesn't. Right one is the visual with Filter measure.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

7 REPLIES 7
Ivancito111
Resolver I
Resolver I

.

Anonymous
Not applicable

Hi @Ivancito111 

I suggest you to create an unrelated Period table to create the slicer. Then create a measure to calcualte Balance dynamicly filtered by this slicer and create another measure to filter this visual dynamic by this slicer.

 

Period = VALUES('Table'[Period])

 

Measures:

 

M_Balance =
VAR _SelectPeriod =
    IF (
        ISFILTERED ( Period[Period] ),
        SELECTEDVALUE ( Period[Period] ),
        MAX ( Period[Period] )
    )
VAR _SumbyCompany =
    CALCULATE (
        SUM ( 'Table'[Balance] ),
        FILTER ( 'Table', 'Table'[Period] <= _SelectPeriod )
    )
RETURN
    _SumbyCompany
Filter =
VAR _SelectPeriod =
    IF (
        ISFILTERED ( Period[Period] ),
        SELECTEDVALUE ( Period[Period] ),
        MAX ( Period[Period] )
    )
VAR _SumbyCompany =
    CALCULATE (
        SUM ( 'Table'[Balance] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Company] = MAX ( 'Table'[Company] )
                && 'Table'[Period] <= _SelectPeriod
        )
    )
RETURN
    _SumbyCompany

 

Create a Matrix, add [Filter] measure into filter field and set it to show items when value =1.

By Defualt:

1.png

Select 202108, all company will show values before 202108.(2108,2107,2106)

2.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

Hello, thank you very much for your answer, the filter works correctly but it does not remove the 0 values from the matrix.

I copied and pasted what you did, and it does not work, I still get the $ 0.

 

I don't understand why this is wrong, since I replicated the same thing you did in my test data (the animal company) and it works correctly but in the real data, they still appear.

 

Filter = 
var __SelectPeriod =
    IF(
        ISFILTERED( Slicer[Periodo]),
        SELECTEDVALUE(Slicer[Periodo]),
        MAX(Slicer[Periodo])
    )

var __SumbyCompany =
    CALCULATE(
        SUM(Creditos[Saldo]),
        FILTER(
            ALL(Creditos),
            Creditos[Nombre] = MAX( Creditos[Nombre])
                && Creditos[Periodo] <= __SelectPeriod
        )
    )
return 
    __SumbyCompany

 

M_Saldo = 
var __SelectPeriod = 
    IF(
        ISFILTERED(Slicer[Periodo]),
        SELECTEDVALUE(Slicer[Periodo]),
        MAX(Slicer[Periodo])
    )
var __SumbyCompany = 
    CALCULATE(
        SUM(Creditos[Saldo]),
        FILTER( Creditos, Creditos[Periodo] <= __SelectPeriod)
    )

return 
    __SumbyCompany

 

Sin título.png

For security reasons I cannot send you more information about my company.

 

Regards,

Anonymous
Not applicable

Hi @Ivancito111 

Please check whether [Period] column you use in slicer has relationship with your data table. You need to create an unrelated table and then create measures based on this [Period]. Relationship will impact your calculate and return incorrect result.

 

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

After re-analyzing my data, I found the problem, added it to the data test, and now I realize that what you did doesn't work either, it keeps showing you zeros.

 

I added this row to the data in the file you sent me, obviously since a company can have more than one credit.

 

21rabbitUF -2Estadotake2021101000 1000

 

And this is what happens with the matrix

 

Ivancito111_0-1636639653135.png

If you notice the credit UF - 1, from the Rabbit company is not eliminated from the matrix and shows zero, my idea is that this zero does not exist, since it was paid.

 

Regards,

 

Anonymous
Not applicable

Hi @Ivancito111 

I think you can add some filter in your Filter measure to achieve your goal.

New code:

M_Filter = 
VAR _SelectPeriod =
    IF (
        ISFILTERED ( Period[Period] ),
        SELECTEDVALUE ( Period[Period] ),
        MAX ( Period[Period] )
    )
VAR _SumbyCompany =
    CALCULATE (
        SUM ( 'Table'[Balance] ),
        FILTER (
            ALL ( 'Table' ),
            'Table'[Company] = MAX ( 'Table'[Company] )
                && 'Table'[ID_Credit] = MAX ( 'Table'[ID_Credit] )
                && 'Table'[Bank] = MAX ( 'Table'[Bank] )
                && 'Table'[Period] <= _SelectPeriod
        )
    )
RETURN
    _SumbyCompany

You see in my new Table I add UF-2 in rabbit as well, UF-1 will return 0 and UF-2 doesn't. Right one is the visual with Filter measure.

1.png

Best Regards,
Rico Zhou

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

I don't understand how you did it, but thank you very much, it's just what I needed ❤️

 

I love You

Helpful resources

Announcements
November Power BI Update Carousel

Power BI Monthly Update - November 2025

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

Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

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.

Top Solution Authors
Top Kudoed Authors