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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Sum rows base on another column values and remove rows if net to zero

Good Day All,

 

I'd like to remove the rows if Type = Balance, Revalue Flag = N  and its  Equal Base amount is net to zero and Base Amt is Blank

Thanks in advance.

Acct     Base Amt         Currency Bal          Equal Base           Amt Type    Revalue Flag
1000                                  -150                  -100                    Balance            N
1000                                   150                    100                    Balance            N
2000                                                           - 300                   Transaction      Y
2000                                                             300                   Transaction       Y                                  

3000                                 100                      110                    Balance            Y

3000                                 -100                    -110                    Balance           Y

4 REPLIES 4
v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

Use the following dax :

Amttype2 =
VAR baseamt =
    IF ( MAX ( 'Table'[Base Amt ] ) = BLANK ()01 )
VAR sumequal =
    CALCULATE (
        SUM ( 'Table'[Equal Base ] ),
        FILTER ( ALL ( 'Table' ), 'Table'[Acct  ] = MAX ( 'Table'[Acct  ] ) )
    )
VAR equal =
    IF ( sumequal = 001 )
VAR amt =
    IF ( MAX ( 'Table'[Amt Type] ) = "Balance"01 )
VAR revalue =
    IF ( MAX ( 'Table'[Revalue Flag] ) = "N"01 )
VAR total = baseamt + equal + amt + revalue
VAR last =
    IF ( total = 0BLANK ()MAX ( 'Table'[Amt Type] ) )
RETURN
    last

 

 

Then you will see:

v-luwang-msft_0-1614143289029.png

 

Best Regard

Lucien Wang

Anonymous
Not applicable

Thanks, actually, i want to remove the 1st and second line. If  Sum of accounts Equal Base = 0, Base Amt=0 Amt type = Balance, Revalue flag = N

 

v-luwang-msft
Community Support
Community Support

Hi @Anonymous ,

You could try the following measure to create a new table ,and new table will remove what you want :

solution 1,

Table 2 = CALCULATETABLE('Table',FILTER(ALL('Table'),'Table'[Amt Type]<>"Balance"||'Table'[Base Amt ]<>BLANK()||'Table'[Revalue Flag]<>"N"||'Table'[Equal Base ]<>0))

Before:

v-luwang-msft_0-1613983949559.png

 

   

New:

v-luwang-msft_1-1613983949564.png

 

 

solution 2,

Create measure use following dax:

Measure=

var baseamt=IF(MAX('Table'[Base Amt ])=BLANK(),0,1)  

var equal=IF(max('Table'[Equal Base ])=0,0,1) 

var amt=if(MAX('Table'[Amt Type])="Balance",0,1)  

var revalue=IF(MAX('Table'[Revalue Flag])="N",0,1)

var total=baseamt+equal+amt+revalue  

return total

v-luwang-msft_2-1613983949573.png

 

v-luwang-msft_3-1613983949575.png

 

Then create table base on the measure:

Table 3 = CALCULATETABLE('Table',FILTER(ALL('Table'),'Table'[measure]<>0))

v-luwang-msft_4-1613983949580.png

 

 

Hope it helpful for you!

 

Click  here  to download pbix if you need.

 

Best Regard

Lucien Wang

amitchandak
Super User
Super User

@Anonymous , Looking at data you will not get any row as all account sum is 0. what is the expected output?

 

A measure like this

sumx(filter(summarize(filter(Table, not (Table[Type] = "Balance" && table[Revalue Flag] = "N")), Table[Acc], "_1", Sum(Table[Equal Base])),[_1]<>0),[Equal Base])

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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