cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
PTSS
Frequent Visitor

how to create formula for new amount column based on account

Site   Type    Period              Account       Amount
BD1   ANF    2022-09-15     Thujan          4
BD1   ANF    2022-09-16     Thujan          4
BD1   ANF    2022-09-15     Factor           0.3
BD1   ANF    2022-09-16     Factor           0.3
BD1   ANF    2022-09-15     Slippery        1.2
BD1   ANF    2022-09-16     Slippery        1.2

 

i want to create a new column with sum of values ​​by account,

 

I've tried this formula but it doesn't work

Amount THujan = CALCULATE([Amount], SS_Account="Thujan")

 

is there any other way?

2 ACCEPTED SOLUTIONS
MahyarTF
Memorable Member
Memorable Member

Hi,

you could use the below code for creating the column :

NewAmount = CALCULATE(sum(Sheet56[amount]), all(Sheet56), Sheet56[Account] = EARLIER(Sheet56[Account]))
MahyarTF_0-1669090824583.png

 

Appreciate your Kudos and please mark it as a solution if it helps you 

Mahyartf

View solution in original post

AbbasG
Memorable Member
Memorable Member

@PTSS I think you are missing "SUM" here. Hope it Help's

 

AbbasG_1-1669091373707.png

 

View solution in original post

3 REPLIES 3
FreemanZ
Super User
Super User

try to add a new column with the code below:

 AmountSum =
VAR CurrentAccount = TableName[Account]
RETURN
    CALCULATE(
        SUM(TableName[Amount]),
        TableName[Account] = CurrentAccount,
        ALL()
)
 
I tried and it worked like this:
FreemanZ_0-1669098105853.png

 

AbbasG
Memorable Member
Memorable Member

@PTSS I think you are missing "SUM" here. Hope it Help's

 

AbbasG_1-1669091373707.png

 

MahyarTF
Memorable Member
Memorable Member

Hi,

you could use the below code for creating the column :

NewAmount = CALCULATE(sum(Sheet56[amount]), all(Sheet56), Sheet56[Account] = EARLIER(Sheet56[Account]))
MahyarTF_0-1669090824583.png

 

Appreciate your Kudos and please mark it as a solution if it helps you 

Mahyartf

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

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

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors