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,315
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,078,516
Messages
5,340,879
Members
399,397
Latest member
VolodimiirSr

Some videos you may like

This Week's Hot Topics

  • Problem with Radio Button's format control
    I am creating an employee evaluation template (a sample is below) Column A is the category Column B, C D, E and F will be ratings (unacceptable...
  • Last Display on userform to a Listbox
    [CODE=vba] lstdisplay.ColumnCount = 15 lstdisplay.RowSource = "A1:O600000" [/CODE] So when i do this it Displays everything on the sheet i am...
  • Rename and move files to a new location
    Dear all, I have an excel file with the following information. The actual file name is at column A but i want to rename it using the following...
  • Help with True/False Formula
    Hello! Am stumped how to fix this formula, in which my result returns 'True', but it should return False. =IF(AG2=True...
  • Clear extra characters from a provided range of cells
    Dear All, I have following code which gives me desired output to remove extra characters from a provided range. But it takes too much time when...
  • Help with Current and highest streaks
    Hi there, I've just joined the forum and this is my first post. I've already spent quite a bit of time searching the net and this forum for a...
Top