I have a kusto query that have two columns as shown below & size column is in Giga bytes
Database size
sub1 2541304016738179270
sub2 2539224975164406590
How can I change the Gigabytes into petabytes & create a new column next to “size” using “extend” function or a different way?
1
In Kusto Query Language (KQL), you can convert gigabytes to petabytes by dividing the size in gigabytes by 1,024 (since 1 petabyte is equal to 1,024 terabytes and 1 terabyte is equal to 1,024 gigabytes).
To create a new column next to the “size” column, you can use the extend operator. Here’s how you can do it:
datatable(Database: string, SizeInBytes: long)
[
"sub1", 2541304016738179270,
"sub2", 2539224975164406590
]
| extend SizeInGB = SizeInBytes / (1024 * 1024 * 1024) // Convert bytes to gigabytes
| extend SizeInPB = SizeInGB / 1024 // Convert gigabytes to petabytes
| project Database, SizeInBytes, SizeInGB, SizeInPB
Silver Spade is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
1
I have a kusto query that have two columns as shown below & size column is in Giga bytes. How can I change the Gigabytes into petabytes & create a new column next to “size” using “extend” function or a different way?
As your column is in Gb, You can use below KQL query:
let rithTable=datatable(Database:string, size_gb: long)
[
"cho1", 2541304016738179270,
"cho2", 2539224975164406590
];
rithTable
| extend sz_in_pg = size_gb / 1048576.0
Here,
1 TB = 1024 Gb
1 PB = 1024 Tb
So, 1 PB is 1024*1024 = 1048576 GB
Output:
Fiddle.