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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
ruinaldo
Helper II
Helper II

Measure to sum with left function and only negatives values by row

 

 

i have a table named "Tabela"

I want to do a measure that sum only negative rows, that starts with 24 and conta movimento is yes.

 

ruinaldo_2-1606008778944.png

I tried this measure but don´t work.

ruinaldo_0-1606008415270.png

 

How can i do that?

 

 

2 ACCEPTED SOLUTIONS
AlB
Community Champion
Community Champion

Hi @ruinaldo 

Measure =
SUMX (
    CALCULATETABLE (
        DISTINCT ( Tabela[Conta] ),
        Tabela[Conta movimento] = "Yes",
        Tabela[Saldo] > 0,
        LEFT ( Tabela[Conta], 2 ) = "24"
    ),
    CALCULATE ( SUM ( Tabela[Saldo] ) )
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

View solution in original post

Anonymous
Not applicable

Hi @ruinaldo ,

Based on your description, you can create a measure as follows.

 

_sum =
SUMX(
FILTER(
'Sheet1',
LEFT('Sheet1'[Conta],2)="24"&&[conta]=SELECTEDVALUE('Sheet1'[conta])
),
[Saldofinal])
 
Result:
 

v-yuaj-msft_0-1606267196545.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

5 REPLIES 5
Anonymous
Not applicable

Hi @ruinaldo ,

Based on your description, you can create a measure as follows.

 

_sum =
SUMX(
FILTER(
'Sheet1',
LEFT('Sheet1'[Conta],2)="24"&&[conta]=SELECTEDVALUE('Sheet1'[conta])
),
[Saldofinal])
 
Result:
 

v-yuaj-msft_0-1606267196545.png

 

Hope that's what you were looking for.

Best Regards,

Yuna

 

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

ruinaldo
Helper II
Helper II

Hi, thank you very much for the formula, you are great.

but i have another question...i want to check the negative saldo by accumulate the conta by month.

Here is an simple example:

i have this table. I delete the column conta movimento to simplify

 

ruinaldo_2-1606151418452.png

 

In month 0 your formula is correct

ruinaldo_0-1606151331855.png

 

But In month 0+1 is wrong. I want to check the accumate saldo negative of conta by month

The corret is conta 24371 have accumulate saldo of 11535.32

The another conta have positive accumate saldo. Check the conta 24241...have positive saldo in month 0+1, so don´t have to consider

 

Your formula give me in month 0+1 this result

ruinaldo_1-1606151362576.png

 

AlB
Community Champion
Community Champion

@ruinaldo 

I would say go ahead and convert it to text. Check if the result is consistent with the numbers you had. OTherwise you can keep it as number and extract the two first digits as number

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

ruinaldo
Helper II
Helper II

Give me a error....

ruinaldo_0-1606127193331.png

I think have this problem because "Table[Conta] is in text.

How can i resolve that? I´m working in direct query and when i choose text give me that:

ruinaldo_1-1606127848076.png

AlB
Community Champion
Community Champion

Hi @ruinaldo 

Measure =
SUMX (
    CALCULATETABLE (
        DISTINCT ( Tabela[Conta] ),
        Tabela[Conta movimento] = "Yes",
        Tabela[Saldo] > 0,
        LEFT ( Tabela[Conta], 2 ) = "24"
    ),
    CALCULATE ( SUM ( Tabela[Saldo] ) )
)

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

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! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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