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
Joined
Oct 7, 2016
Messages
91
Office Version
  1. 2019
Platform
  1. Windows
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.
<tbody> [TD="width: 150, bgcolor: transparent"]
A
[/TD]
[TD="width: 150, bgcolor: transparent"]
B
[/TD]
[TD="width: 150, bgcolor: transparent"]
C
[/TD]
[TD="width: 150, bgcolor: transparent"]
D
[/TD]
[TD="width: 150, bgcolor: transparent"] Year [/TD]
[TD="width: 150, bgcolor: transparent"] User ID [/TD]
[TD="width: 150, bgcolor: transparent"] Service Cost [/TD]
[TD="width: 150, bgcolor: transparent"] Standard Cost [/TD]
[TD="width: 150, bgcolor: transparent"] 2019 [/TD]
[TD="width: 150, bgcolor: transparent"] A230 [/TD]
[TD="width: 150, bgcolor: transparent"] £150 [/TD]
[TD="width: 150, bgcolor: transparent"] £200 [/TD]
[TD="width: 150, bgcolor: transparent"] 2019 [/TD]
[TD="width: 150, bgcolor: transparent"] A230 [/TD]
[TD="width: 150, bgcolor: transparent"] £20 [/TD]
[TD="width: 150, bgcolor: transparent"] £200 [/TD]
[TD="width: 150, bgcolor: transparent"] 2019 [/TD]
[TD="width: 150, bgcolor: transparent"] A230 [/TD]
[TD="width: 150, bgcolor: transparent"] £10 [/TD]
[TD="width: 150, bgcolor: transparent"] £200 [/TD]
[TD="width: 150, bgcolor: transparent"] 2019 [/TD]
[TD="width: 150, bgcolor: transparent"] F222 [/TD]
[TD="width: 150, bgcolor: transparent"] £40 [/TD]
[TD="width: 150, bgcolor: transparent"] £50 [/TD]
[TD="width: 150, bgcolor: transparent"] 2019 [/TD]
[TD="width: 150, bgcolor: transparent"] F222 [/TD]
[TD="width: 150, bgcolor: transparent"] £20 [/TD]
[TD="width: 150, bgcolor: transparent"] £50 [/TD]
</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

 

Excel Facts

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"
like this?

[Table="width:, class:head"]
[tr=bgcolor:#FFFFFF][td=bgcolor:#5B9BD5]Year[/td][td=bgcolor:#5B9BD5]User ID[/td][td=bgcolor:#5B9BD5]Service Cost[/td][td=bgcolor:#5B9BD5]Standard Cost[/td][td][/td][td=bgcolor:#70AD47]Year[/td][td=bgcolor:#70AD47]User ID[/td][td=bgcolor:#70AD47]Service Cost[/td][td=bgcolor:#70AD47]Standard Cost[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
2019​
[/td][td=bgcolor:#DDEBF7]A230[/td][td=bgcolor:#DDEBF7]
150​
[/td][td=bgcolor:#DDEBF7]
200​
[/td][td][/td][td=bgcolor:#E2EFDA]
2019​
[/td][td=bgcolor:#E2EFDA]A230[/td][td=bgcolor:#E2EFDA]
180​
[/td][td=bgcolor:#E2EFDA]
200​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td]
2019​
[/td][td]A230[/td][td]
20​
[/td][td]
200​
[/td][td][/td][td]
2019​
[/td][td]F222[/td][td]
60​
[/td][td]
50​
[/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
2019​
[/td][td=bgcolor:#DDEBF7]A230[/td][td=bgcolor:#DDEBF7]
10​
[/td][td=bgcolor:#DDEBF7]
200​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td]
2019​
[/td][td]F222[/td][td]
40​
[/td][td]
50​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]

[tr=bgcolor:#FFFFFF][td=bgcolor:#DDEBF7]
2019​
[/td][td=bgcolor:#DDEBF7]F222[/td][td=bgcolor:#DDEBF7]
20​
[/td][td=bgcolor:#DDEBF7]
50​
[/td][td][/td][td][/td][td][/td][td][/td][td][/td][/tr]
[/table]


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:
Upvote 0
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;

 
Upvote 0

Forum statistics

Threads
1,223,239
Messages
6,170,947
Members
452,368
Latest member
jayp2104

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