100% found this document useful (1 vote)
253 views64 pages

2 - Power BI - Query Editor - Column Transformation - Data Types

Power BI allows users to transform columns in various ways such as renaming columns, adding or removing columns, splitting columns, merging columns, unpivoting columns, transposing columns, and changing column data types. Column transformations can be performed using options in the Query Editor ribbon interface or contextual menus with just a click.

Uploaded by

Sunilkumar Dubey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
100% found this document useful (1 vote)
253 views64 pages

2 - Power BI - Query Editor - Column Transformation - Data Types

Power BI allows users to transform columns in various ways such as renaming columns, adding or removing columns, splitting columns, merging columns, unpivoting columns, transposing columns, and changing column data types. Column transformations can be performed using options in the Query Editor ribbon interface or contextual menus with just a click.

Uploaded by

Sunilkumar Dubey
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
Download as pdf or txt
Download as pdf or txt
You are on page 1/ 64

Power BI

Power BI Query Editor


Columns
Transformation
◦ There certain important column transformation
options already in built in Query ribbon interface.
You can use these column transformation options
with just simple click of mouse button.
◦ The Transform-tab in the query editor is sensitive
to the columns you select. So if you select multiple
number columns for example, some number
transformations will be greyed out and are
therefore not accessible:
COLUMNS TRANSFORMATION
Get Data
◦ Select: Home → Get Data → Excel
◦ Click on file named ‘Column & Row
Transformation’
◦ Click on ‘Open’ button
Navigator
◦ Select (tick mark) table ‘Column_Row’ under
Navigator
◦ Click on ‘Transform Data’ button to bring data
in Query Editor
DATA IN QUERY
EDITOR
NAME
COLUMNS
Rename Column
Header
◦ Select column Header name ‘Invoice’
◦ Click on ‘Transform’
◦ Click on ‘Rename’
◦ Type new name as ‘Invoice No’
Three Ways to
Name/Rename a
Column Heading
◦ Click on column Header named ‘Invoice’; Transform
→ Any Column → Rename; type new name as
‘Invoice No’ → press ENTER key to finish
OR
◦ Right Click on Column Header; say ‘Invoice’ column
header and select ‘Rename’ option, then type new
name ‘Invoice No’ → press ENTER key to finish
OR
◦ Double click on Header name; say ‘Invoice’ column
and type ‘Invoice No’→ press ENTER key to finish
ADD COLUMNS
Add Custom
Columns
◦ In ‘Column_Row’ table
showing ‘Quantity’ and
‘Total’ column but ‘Rate
Per Unit’ column is
missing
◦ Click on ‘Add Column’
ribbon → Click on
‘General’ → ‘Custom
Column’
◦ Type ‘Rate Per Unit’ in
New Column name field
◦ Type ‘Custom Column
formula:
=[Amount]/[Quantity]
◦ Click on ‘Ok’
Change Data Type
of ‘Total’ column
◦ Click to select ‘Total’ column header
◦ Select ‘Transform’ →Any Column → Data
Type → Decimal Number
REMOVE
COLUMNS
To remove unwanted column:

Remove Column ◦ Click on Column Header name; Say ‘Invoice Date’


to select the column and then select → Home →
Manage Columns → Remove Columns
OR

Remove Column To remove unwanted column:


◦ Right click on Column Header name and from pop
up select → Remove
Remove Other
Columns
◦ You can hold SHIFT key to select subsequent
columns in order.
◦ You can use CTRL key to select individual
columns not is sequential order.
◦ Select Header ‘Product Name’; then hold
SHIFT and click on ‘Amount’ header to select
subsequent column; then press and hold CTRL
key and click on ‘Customer Name’ to highlight
it.
◦ Then follow steps: Home → Manage Columns
→ Remove Columns → Remove Other
Columns
DEPENDING ON
ORDER YOU
SELECTED THE
COLUMNS THEY
GET ARRANGED
Column Filter -
‘Choose Columns’
◦ You can use ‘Choose Columns’ filter to remove
unwanted columns
◦ Follow steps: Home → Manage Columns →
Choose Columns
◦ Remove tick mark from ‘Select All Columns’
◦ Tick mark column header you want, say –
‘Customer Name’, ‘Product Name’, ‘Quantity’,
and ‘Amount’
◦ Click ‘Ok’
SPLIT
COLUMNS
Split Columns Using Delimiters
◦ Select ‘Shipping Address’ column
◦ Follow: ‘Transform’ tab → ‘Text Column’ group → ‘Split Column’ drop down button → ‘By Delimiter’
option
◦ Selecting the By Delimiter option will open the following window.
◦ Select or enter delimiter: Please select the delimiter that you want to use as the split character from the drop down
list. If it is not there in the list, then select Custom option and specify that custom character.
◦ Left most delimiter: This option will split the left most string before first delimiter.
◦ Right most delimiter: This option will split right most string after the last delimiter.
◦ Each Occurrence of the delimiter: Text will split at each occurrence of a delimiter.
◦ Select ‘Comma’ as
◦ Select ‘Each Occurrence of the delimiter’
◦ Click ‘Ok’
MERGE
COLUMNS
◦ Merge Column (select three column which was
Merge Columns split) merge from transform Tab and merge by
coma
SHORT
COLUMNS
Re-arrange or Sort the Column ( by click the
column and dragging to place the column ). You
SHORT COLUMNS can you SHIFT key to select multiple column
and CTRL key to select individual column away
from each other.
UNPIVOT
COLUMNS
Unpivot Columns
◦ To unpivot columns:
◦ Go to : Home → Recent Sources
◦ Click on recently imported file in list named
‘Column_Row Trnsformations.xlsx’
◦ Select table name ‘unpivot1’
◦ Click on ‘Edit/Transform Data’
There are Three options to unpivot columns under
‘Transform’
Unpivot 1. Unpivot Columns

Columns 2. Unpivot Other Columns


3. Unpivot Only Selected Columns
◦ Power BI Unpivot Columns feature converts the data
headers stored horizontally into a vertical format i.e.
Power Query Column to Rows. The chosen columns are
then split in two columns i.e. Attribute and Value.
Unpivot ◦ Attribute represents the header of the columns chosen for

Columns Power BI Unpivot Columns


◦ Value represents the value which was present under the
header’s column previously
◦ In other words, data gets rotated from horizontal to
vertical when Unpivot Columns feature is applied.
1. Click on column header ‘2009’, hold down SHIFT
key and click on column header ‘2016’ , then click
on ‘Transform’ → ‘Any Column’ → Unpivot
Columns → Unpivot Columns
OR
Unpivot 2. Click to select all columns except columns 2009 to

Column Year 2016, then click on ‘Transform’ → ‘Any Column’


→ Unpivot Columns → Unpivot Other Columns

2009 to 2016 OR
3. Select the column you want to unpivot, then click
on ‘Transform’ → ‘Any Column’ → Unpivot
Columns → Unpivot Only Selected Columns
Pivot the
Unpivoted Column
◦ Select ‘Attribute’ Column to unpivot it once
again as it was before.
◦ Click on ‘Transform’ → ‘Any Column’ →
‘Pivot Column’
◦ Select Value Column as ‘Value’
◦ Under ‘Advance Aggregate Value function’
select ‘Don’t Aggregate’
◦ Click on ‘Ok’
TRANSPOSE
COLUMNS
Transpose Columns ◦ Transposing a data set is ultimately rotating data
from rows to columns, or from columns to rows.
Transpose
Columns
◦ To Transpose columns:
◦ Go to : Home → Recent Sources
◦ Click on recently imported file in list named
‘Column_Row Trnsformations.xlsx’
◦ Select table name ‘transpose2’
◦ Click on ‘Ok’
Transpose
Columns
◦ To bring header as first
row: Go to → Transform
→ Table → Select ‘Header
as First Row’
Transpose
Columns
◦ Select ‘Transform’ →
‘Table’ → ‘Transpose’
Transpose
Columns
◦ Now select → ‘Transform’
→ ‘Table’ → ‘Use First
Row as Headers’
COLUMN ‘DATA
TYPES’
Column – Data Types
◦ For performing mathematical operation you need to check data
type of the Column
◦ Data types supported by Microsoft is as shown in image:
Data Type – ‘Decimal Number’
◦ Decimal Number – Represents a 64 bit (eight-byte) floating point
number. Although designed to handle numbers with fractional
values, it also handles whole numbers. The Decimal Number type
can handle negative values from -1.79E +308 through -2.23E -308,
0, and positive values from 2.23E -308 through 1.79E + 308. For
example, numbers like 34, 34.01, and 34.000367063 are valid decimal
numbers. The largest value that can be represented in a Decimal
Number type is 15 digits long. The decimal separator can occur
anywhere in the number. The Decimal Number type corresponds to
how Excel stores its numbers.
Data Type – ‘Fixed Decimal Number’
◦ Fixed Decimal Number – Has a fixed location for the decimal
separator. The decimal separator always has four digits to its right
and allows for 19 digits of significance. The largest value it can
represent is 922,337,203,685,477.5807 (positive or negative). The
Fixed Decimal Number type is useful in cases where rounding might
introduce errors. When you work with many numbers that have
small fractional values, they can sometimes accumulate and force a
number to be slightly off. Since the values past the four digits to the
right of decimal separator are truncated, the Fixed Decimal type can
help you avoid these kinds of errors. If you’re familiar with SQL
Server, this data type corresponds to SQL Server’s Decimal (19,4), or
the Currency Data type in Power Pivot.
Data Type – ‘Whole Number’
◦ Whole Number – Represents a 64 bit (eight-byte) integer value.
Because it’s an integer, it has no digits to the right of the decimal
place. It allows for 19 digits; positive or negative whole numbers
between -9,223,372,036,854,775,807 (-2^63+1) and
9,223,372,036,854,775,806 (2^63-2). It can represent the largest
possible number of the various numeric data types. As with the
Fixed Decimal type, the Whole Number type can be useful in cases
where you need to control rounding.
Data Type – ‘Percentage’
◦ Percentage was added as fourth numeric data type to the Query
Editor/M in November of 2016. Unlike whole number, fixed
decimal number, and decimal number, this type does not have a
corresponding type in the data model.
◦ When loaded to the data model, the percentage data type is
represented as a decimal number type.
Data Type – ‘Date/Time’
◦ Date/Time – Represents both a date and time value. Underneath
the covers, the Date/Time value is stored as a Decimal Number
Type. So you can actually convert between the two. The time portion
of a date is stored as a fraction to whole multiples of 1/300 seconds
(3.33 ms). Dates between years 1900 and 9999 are supported.
Data Type – ‘Date’
◦ Date – Represents just a Date (no time portion). When converted
into the model, a Date is the same as a Date/Time value with zero
for the fractional value.
Data Type – ‘Time’
◦ Time – Represents just Time (no Date portion). When converted
into the model, a Time value is the same as a Date/Time value with
no digits to the left of the decimal place.
Data Type – ‘Date/Time/Timezone’
◦ Date/Time/Timezone – Represents a UTC Date/Time.
Currently, it’s converted into Date/Time when loaded into the
model.
Data Type – ‘Duration’
◦ Duration – Represents a length of time. It’s converted into a
Decimal Number Type when loaded into the model. As a Decimal
Number type it can be added or subtracted from a Date/Time field
with correct results. As a Decimal Number type, you can easily use it
in visualizations that show magnitude.
Data Type – ‘Text’
◦ Text - A Unicode character data string. Can be strings, numbers, or
dates represented in a text format. Maximum string length is
268,435,456 Unicode characters (256 mega characters) or
536,870,912 bytes.
Data Type – ‘True/False’
◦ True/False – A Boolean value of either a True or False.
◦ Binary data types are used to store any kind of binary data
like images, word files, text files, etc. in table.
◦ Data types in the binary-strings category include:
◦ bit variables store a single bit with a value of 0, 1 or NULL.

Data Type – ◦ binary(n) variables store n bytes of fixed-size binary data. These
fields may store a maximum of 8,000 bytes.

‘Binary’ ◦ varbinary(n) variables store variable-length binary data of


approximately n bytes. They may store a maximum of 8,000 bytes.
◦ varbinary(max) variables store variable-length binary data of
approximately n bytes. They may store a maximum of 2 GB and
actually store the length of the data plus an additional two bytes.
◦ image variables store up to 2 GB of data and are commonly used
to store any type of data file (not just images).
◦ Blank - Is a data type in DAX that represents and replaces
SQL nulls. You can create a blank by using the BLANK
function, and test for blanks by using the ISBLANK logical
Data Type – function.

Blank/Null ◦ NULL is not the number zero. NULL is not the empty string
(“”) value. Rather, NULL is the value used to represent an
unknown piece of data. A NULL is an unknown value in
which the field appears blank.
Data Type – ‘Any’
◦ When data type is undefined for a column

You might also like