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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

Reply
JSData
Frequent Visitor

Add column or replace value?

Hello, I'm having some trouble puting a formula together to add a column that will return Sub Account 12345 for the first row in the table below. The account number for the department that needs to be replaced will always be 236. 

AccountSub AccountInvoice NumberAmount
236000005555-10
52612345555520
20500000555530

 

1 ACCEPTED SOLUTION
v-xinruzhu-msft
Community Support
Community Support

Hi @JSData 

You can create a new column:

Column = var a=FILTER('Table',[Invoice Number]=EARLIER('Table'[Invoice Number]))
return IF([Amount]>0,[Sub Account],MAXX(a,[Sub Account]))

vxinruzhumsft_0-1672277757795.png

Best Regards!

Yolo Zhu

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

4 REPLIES 4
v-xinruzhu-msft
Community Support
Community Support

Hi @JSData 

You can create a new column:

Column = var a=FILTER('Table',[Invoice Number]=EARLIER('Table'[Invoice Number]))
return IF([Amount]>0,[Sub Account],MAXX(a,[Sub Account]))

vxinruzhumsft_0-1672277757795.png

Best Regards!

Yolo Zhu

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

FreemanZ
Super User
Super User

hi @JSData 

Not sure if i fully get you, try to create a column like this:
Result =
VAR _invoice = [Invoice Number]
RETURN
MAXX(
    FILTER(
         data, 
         data[Invoice Number]=_invoice
    ),
    data[Sub Account]
)
JSData
Frequent Visitor

@Arul 

I have to apolgize I did not put enough detail in my orignal post. Your solution will work if it's only one replacement. The problem I'm working on is for each invoice number that has this account number I need to correct subaccount to be assigned to that account. I've put an expanded table with a desired result column that hopefully explains this more clearly. Again I apologize for being unclear the first time.

AccountSub AccountInvoice NumberAmountDesired result
236000005555-1012345
5261234555552012345
2050000055553000000
236000005554-1012343
5261234355542012343
2050000055543000000
5261233352532012333
Arul
Super User
Super User

@JSData ,

try this formula in calculated column,

Sub account new =
VAR _value = 12345
VAR _result =
    IF ( 'Test Table'[Account] = 236, _value, 'Test Table'[Sub Account] )
RETURN
    _result

Thanks,

Arul





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!


LinkedIn


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!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.