# I need two Formulas to help me display the cost in Power Bi: one for total cost and one for single cost:

#### Leicester City Fox

##### Board Regular
I need two Formulas to help me display the cost in Power Bi: one for total cost and one for single cost:

1. Formula One Request: I need it to add up thetotal cost of services (column C) per user (column B). Example, User ID A230would be £180 and User id F222 wouldbe £60.

2. Formula Two Request: I need it to only show thestandard cost (column D) per user id Column B) once as it stays the same. Example,User ID A230 would just pick up once that it only Total standard cost is £200& user id F222 would be £50. in other words, it don’t add up all thestandard cost figure but just shows once so it If I totalled both users in thisexample the standard total would be £250.
 A​ B​ C​ D​ Year User ID Service Cost Standard Cost 2019 A230 £150 £200 2019 A230 £20 £200 2019 A230 £10 £200 2019 F222 £40 £50 2019 F222 £20 £50
<tbody> </tbody>

Any help for a simple formula which would add up all Servicecost and a second Formula that adds up Standard cost figure once would be much appreciated.
Many Thanks
The Leicester Fox

#### sandy666

##### Well-known Member
like this?

 Year User ID Service Cost Standard Cost Year User ID Service Cost Standard Cost 2019​ A230 150​ 200​ 2019​ A230 180​ 200​ 2019​ A230 20​ 200​ 2019​ F222 60​ 50​ 2019​ A230 10​ 200​ 2019​ F222 40​ 50​ 2019​ F222 20​ 50​

Code:
``````[SIZE=1]// Table1
let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
Group = Table.Group(Source, {"Year", "User ID"}, {{"Service Cost", each List.Sum([Service Cost]), type number}, {"Count", each _, type table}}),
List = Table.AddColumn(Group, "Standard Cost", each List.Distinct(Table.Column([Count],"Standard Cost"))),
Expand = Table.ExpandListColumn(List, "Standard Cost")
in
Expand[/SIZE]``````

Last edited:

#### Leicester City Fox

##### Board Regular
Hi Sandy666
Good Morning
That what I amlooking for the results in the green table.

In relation to making the code work do I just type it into formulabar in power bi, sorry I am at bit new to power bi or is it easier to do it in excel and importinto power bi?
Thank for your thoughts on the matter &#55357;&#56842;

#### sandy666

##### Well-known Member
I don't know a few details but here is an PBI example

1,081,932
Messages
5,362,214
Members
400,672
Latest member
ExcelGrasshopper

### This Week's Hot Topics

• populate from drop list with multiple tables
Hi All, i have a drop list that displays data, what i want is when i select one of those from the list to populate text from different tables on...
• Find list of words from sheet2 in sheet1 before a comma and extract text vba
Hi Friends, Trying to find the solution on my task. But did not find suitable one to the need. Here is my query and sample file with details...
• Dynamic Formula entry - VBA code sought
Hello, really hope one of you experts can help with this - i've spent hours on this and getting no-where. .I have a set of data (more rows than...