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
53
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
Joined
Oct 24, 2015
Messages
3,232
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:

Leicester City Fox

Board Regular
Joined
Oct 7, 2016
Messages
53
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;

 

Forum statistics

Threads
1,077,920
Messages
5,337,196
Members
399,131
Latest member
Vinnyjuice

Some videos you may like

This Week's Hot Topics

Top