The ultimate Microsoft Fabric, Power BI, Azure AI, and SQL learning event: Join us in Stockholm, September 24-27, 2024.
Save €200 with code MSCUST on top of early bird pricing!
Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started
Hi,
I've got this table and want to divide Sum of DiskSizeInGB by number of same Srv-computers.
(In the source data I get, total Sum of DiskSize per server, is listed per app)
Srv-computer | App | Sum of DiskSizeInGB | SizePerApp |
TST03310 | 1 | 610 | 305 |
TST03310 | 2 | 610 | 305 |
TFSTS131551 | A | 124751 | 41583.7 |
TFSTS131551 | B | 124751 | 41583.7 |
TFSTS131551 | C | 124751 | 41583.7 |
TFXTV120014 | J | 320 | 320 |
I got this far, but get a error:
let
Source = Excel.Workbook(File.Contents(".......\Storage analysis 20220518.xlsx"), null, true),
Table1_Table = Source{[Item="Table1",Kind="Table"]}[Data],
#"Added Custom" =
Table.AddColumn(Table1_Table, "SizePerApp",
each [Sum of DiskSizeInGB]/
List.Count(List.Select(Table1_Table[#"Srv-computer"], each _ = [#"Srv-computer"])))
in
#"Added Custom"
Expression.Error: We cannot apply field access to the type Text.
Details:
Value=TST03310
Key=Srv-computer
Is my calculation of number of rows per Srv-computer correct?
Who can help me out?
Thanks in advance!
Solved! Go to Solution.
Replace each _ = [#"Srv-computer"] with (x)=>x= [#"Srv-computer"]
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCgkOMTA2NjRQ0lEyBGIzICtWB0XYCFnYLTgk2NDY0NQUpNgRpMnIxBzIwZR0wifpjC4ZERJmaGRgYGgClPACYmMjoIWxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Srv-computer" = _t, App = _t, #"Sum of DiskSizeInGB" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Srv-computer", type text}, {"App", type text}, {"Sum of DiskSizeInGB", Int64.Type}}),
BuffList = List.Buffer(#"Changed Type"[#"Srv-computer"]),
#"Added Custom" = Table.AddColumn(#"Changed Type", "SizePerApp", each Number.Round([Sum of DiskSizeInGB]/List.Count(List.Select(BuffList, (x)=> x=[#"Srv-computer"])),1))
in
#"Added Custom"
Replace each _ = [#"Srv-computer"] with (x)=>x= [#"Srv-computer"]
See the working here - Open a blank query - Home - Advanced Editor - Remove everything from there and paste the below code to test
let
Source = Table.FromRows(Json.Document(Binary.Decompress(Binary.FromText("i45WCgkOMTA2NjRQ0lEyBGIzICtWB0XYCFnYLTgk2NDY0NQUpNgRpMnIxBzIwZR0wifpjC4ZERJmaGRgYGgClPACYmMjoIWxAA==", BinaryEncoding.Base64), Compression.Deflate)), let _t = ((type nullable text) meta [Serialized.Text = true]) in type table [#"Srv-computer" = _t, App = _t, #"Sum of DiskSizeInGB" = _t]),
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Srv-computer", type text}, {"App", type text}, {"Sum of DiskSizeInGB", Int64.Type}}),
BuffList = List.Buffer(#"Changed Type"[#"Srv-computer"]),
#"Added Custom" = Table.AddColumn(#"Changed Type", "SizePerApp", each Number.Round([Sum of DiskSizeInGB]/List.Count(List.Select(BuffList, (x)=> x=[#"Srv-computer"])),1))
in
#"Added Custom"
Great! Works like a charm 🙂
Thanks!
Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.
Check out the August 2024 Power BI update to learn about new features.