IF FUNCTION IN POWER QUERY

aam1932

Board Regular
Joined
Jun 2, 2010
Messages
182
Hai all

Any possible that i want the result to determine D (debit) C (credit) not only based only amount column, but based on the total that particular account in the table as below:
As example, acc_code now currently showing debit amount of 19746434.24, how ever actually i have fews other BU and if i total up all the account code the amount negative, the result in the column D C, should be C and not D.

Thank you

1589735595611.png
 
so post (again) REPRESENTATIVE example where I can sum Amount for the same criteria: BU, FY and ACC
and you didn't answer for my question post#8

anyway all your examples are NOT representative

maybe post a link to the shared excel file with your data via GoogleDrive, oneDrive or any similar
I don't see any confidential data in your examples
 
Upvote 0

Excel Facts

Control Word Wrap
Press Alt+Enter to move to a new row in a cell. Lets you control where the words wrap.
Might it be you are replying to the wrong Guy?
 
Upvote 0
try
Rich (BB code):
let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    Type = Table.TransformColumnTypes(Source,{{"BU", type text}, {"FY", type text}, {"ACC_CODE", type text}, {"AMOUNT", type number}}),
    Group = Table.Group(Type, {"FY", "ACC_CODE"}, {{"Sum", each List.Sum([AMOUNT]), type number}}),
    IF = Table.AddColumn(Group, "DC", each if [Sum] > 0 then "C" else "D"),
    Merge = Table.NestedJoin(Type,{"FY", "ACC_CODE"},Table1,{"FY", "ACC_CODE"},"Table1",JoinKind.LeftOuter),
    Expand = Table.ExpandTableColumn(Merge, "Table1", {"DC"}, {"DC"})
in
    Expand
however it works with your examples but I am not sure it will work with your original data
 
Upvote 0

Forum statistics

Threads
1,223,793
Messages
6,174,624
Members
452,575
Latest member
Fstick546

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top