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.
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

 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
like this?

YearUser IDService CostStandard CostYearUser IDService CostStandard 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:
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,213,522
Messages
6,114,112
Members
448,549
Latest member
brianhfield

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