Jak Na Power Bi Cheat Sheet

Download as pdf or txt
Download as pdf or txt
You are on page 1of 3

OVERVIEW

What is Power BI? Power Query DAX Drill Down License


Works with data fetched from data sources using Language developed for data analysis. It enables the The Visual that supports the embedding of hierarchies Per-user License
"It is Microsoft’s Self-Service Business connectors. This data is then processed at the Power enables drilling down to the embedded hierarchy’s › Free—Can be obtained for any Microsoft work or school
creation of the following objects using expressions:
Intelligence tool for processing and BI app level and stored to an in-memory database in › Measures individual levels using the following symbols: email account. Intended
for personal use. Users with this license can only
analyzing data." the program background. This means that data is not › Calculated Columns
use the personal workspace. They cannot share
processed at the source level. The basic unit in Power › Calculated Tables Drill up to a higher-level hierarchy or consume shared content.
Query is query, which means one sequence Each expression starts with the = sign, followed
Components consisting of steps. A step is a data command that by links to tables/columns/functions/measures and Drill down to a specific field
"If it is not available in Premium workspace"
› Pro—It is associated with a work/school account priced at
dictates what should happen to the data when it is operators. The following operators are supported: €8.40 per month or it is included in the E5 license. Intended for
› Power BI Desktop—Desktop application › Arithmetic { + , - , / , * , ^ } Drill down to the next level in the hierarchy team collaboration. Let's users access team workspaces,
loaded into Power BI. The basic definition of each › Comparison { = , == , > , < , >= , <= , <> }
› Report—Multi-page canvas visible to end users. It serves consume shared content, and use apps.
for the placement of visuals, buttons, images, slicers, etc.
step is based on its use: › Text concatenation { & , && , II , IN } Expand next-level hierarchy › Premium per User – Includes all Power BI Pro license
› Data—Preview pane for data loaded into a model. › Connecting data—Each query begins with a function that › Precedence { ( , ) } capabilities, and adds features such as paginated reports, AI,
› Model—Editable scheme of relationships between tables in provides data for the subsequent steps. E.g., data can be Operators and functions require that all greater frequency for refresh rate, XMLA endpoint and other
loaded from Excel, SQL database, SharePoint etc. Connection
a model. Pages can be used in a model for easier navigation.
› Power Query—A tool for connecting, transforming,
steps can also be used later.
values/columns used are of the same data type
or of a type that can be freely converted; such
Tooltip/Custom Tooltip capabilities that are only available to Premium subscribers.
Per-tenant License
› Transforming data—Steps that modify the structure of the › Premium—Premium is set
and combining data. data. These steps include features such as Pivot Column, as a date or a number.
"Apart from the standard version, there is
› Tooltip —A default detail preview pane which up for individual workspaces. 0 to N workspaces
converting columns to rows, grouping data, splitting columns, appears above a visual when you hover over its values. can be used with a single version of this license. It provides
also a version for Report Server." removing columns, etc. Transformation steps are necessary in dedicated server computing power based
› Power BI Service—A cloud service enabling access
to, and sharing and administration of, output data.
order to clean data from not entirely clean data sources.
› Combining data—Data split into multiple source files needs Visualization on license type: P1, P2, P3, P4*, P5*. It offers more space for
datasets, extended metrics for individual workspaces,
› Workspace—There are three types of workspaces: to be combined so that it can be analyzed in bulk. Functions managed consumption of dedicated capacity, linking of Azure
include merging queries and appending queries. Visualizations or visuals let you present data in › Custom Tooltip —A custom tooltip is a custom- AI features with datasets, and access for users with Free
Personal, Team, and Develop a template app. They serve
as storage and enable controlled access to output data.
› Merge queries—This function merges queries based on the selected various graphical forms, from graphs to tables, designed report page identified as descriptive. licenses to shared
key. The primary query then contains a column which can be used to
› Dashboard—A space consisting of tiles in which visuals and extract data from a secondary query. Supports typical join types: maps, and values. Some visuals are linked to other When you hover over visual, a page appears content. Prices start at €4,212.30.
report pages are stored.* services outside Power BI, such as Power Apps. with content filtered based on criteria specified
*Only available upon special request. Intended for models larger than
100GB.
› Report—A report of pages containing visuals.*
› Worksheet—A published Excel worksheet. Can be used
by the value in the visual. › Embedded—Supports embedding dashboards and reports
in custom apps.
as a tile on a dashboard. › Report Server—Included in Premium or SQL Server Enterprise licenses.
› Dataset—A published sequence for fetching and
transforming data from Power BI Desktop. › Append query—Places the resulting data from one or more selected

Administration
queries under the primary query. In this case, data is placed in columns
› Dataflow—Online Power Query representing
with names that are an exact match. Non-matching columns form new
a special dataset outside of Power BI Desktop.* columns with a unique name in the primary query.
› Application—A single location combining one
In addition to basic visuals, Power BI supports › Use metrics—Usage metrics let you monitor Power BI usage
or more reports or dashboards.* › Custom function—A query intended to apply a pre-defined sequence of creating custom visuals. Custom visuals can be for your organization.
› Admin portal—Administration portal that lets you configure
Drill-through
steps so that the author does not need to create them repeatedly. The › Users—The Users tab provides a link to the Microsoft 365 admin center.
capacities, permissions, and capabilities for individual users custom function can also accept input data (values, sheets, etc.) to be used added using a file import or from a free Marketplace › Audit logs—The Audit logs tab provides a link to the Security &
and workspaces. in the sequence. offering certified and non-certified visuals. Compliance center.
› Parameter—Values independent of datasets. These values can then be › Tenant settings—Tenant settings enable fine-grained control over
*Can be created and edited in the Power BI Service Certification is optional, but it verifies whether, Drill-through lets you pass from a data overview
used in queries. Values enable the quick editing of a model because they features made available to your organization. It controls which features
environment. can be changed in the Power BI Service environment. among other things, a visual accesses external visual to a page with specific details. The target will be enabled or disabled and for which users and groups.
› Data Gateway—On-premises data gateway that lets you services and resources. page is displayed with all the applied filters affecting › Capacity settings—The Power BI Premium tab enables you to
transport data from an internal network or a custom device
to the Power BI Service.
Dataflow the value from which the drill-through originated.
manage any Power BI Premium and Embedded capacities.
› Embed codes—You can view the embed codes that are generated for
your tenant to share reports publicly. You can also revoke or delete codes.
› Power BI Mobile—Mobile app for viewing reports. Mobile
view is applied, if it exists, otherwise the desktop view is used.
The basic unit is a table or Entity consisting of Themes › Organization visuals—You can control which type of Power BI visuals
users can access across the organization.
› Report Server—On-premises version of Power BI Service.
columns or Fields. Just like Queries in Power › Azure connections—You can control workspace-level storage
› Report Builder—A tool for creating page reports. Query, Entities in Dataflows consist of sequences Serves as a single location for configuring all native permissions for Azure Data Lake Gen 2.
of steps. The result of such steps is stored in native › Workspaces—You can view the workspaces that exist in your tenant
graphical settings for visuals and pages. on the Workspaces tab.
Built-in and additional Azure Data Lake Gen 2.
"You can connect a custom Data Lake
› Custom branding—You can customize the look of Power BI for your
whole organization.
languages where the data will be stored." › Protection metrics—The report shows how sensitivity labels help
protect your content.
There are three types of entities: › Featured content—You can manage all the content promoted in the
By default, you can choose from 19 predefined
Built-in languages › Standard entity—It only works with data fetched directly Featured section.
› M/Query Language—Lets you transform data from a data source or with data from non-stored entities themes. Custom themes can be added.
Bookmarks
in Power Query.
› DAX (Data Analysis Expressions)—Lets you define custom
within the same dataflow.
Computed entity*—It uses data from another stored entity
A custom theme can be applied in two different ways:
› Modification of an existing theme—A native window that Bookmarks capture the currently configured view or a
External Tools
calculated tables, columns, and measures in Power BI Desktop. within the same dataflow. lets you modify a theme directly in the Power BI environment. report page visual. Later, you can go back to that state
"Both languages are natively available in Power BI, › Importing a JSON file—Any file you create only defines the They simplify the use of Power BI and extend the
› Linked entity*—Uses data from an entity located in another by selecting the saved bookmark. Setting options:
which eliminates the need to install anything." formatting that should change. Everything else remains the
› Data—Stores filters, applied sort order in visuals and slicers. capabilities offered in Power BI. These tools are
dataflow. If data in the original entity is updated, same. The advantage of this approach is that you can
the new data is directly passed to all By selecting the bookmark, you can re-apply the corresponding mostly developed by the community. Recommended
Additional languages customize any single visual.
settings. external tools:
› Python—Lets you fetch data and create visuals. linked entities.
*Can only be used in a dedicated Power BI Premium workspace. › Display—Stores the state of the display for visuals and › Tabular Editor
Requires installation of the Python language on your "The resulting theme can be exported in the JSON format and report elements (buttons, images, etc.). By selecting the › DAX studio
computer and enabling Python scripting. used in any report without the need to create a theme from
"It supports custom functions as well as parameters." bookmark, you can go back to the previously stored state
› R—Lets you fetch and transform data and create visuals. scratch." of the display. › ALM Toolkit
Requires installation of the R language on your computer
› Current page—Stores the currently displayed page. By › VertiPaq Analyzer
and enabling R scripting.
selecting the bookmark, you can go back the to stored page.

JAK NA POWER POWER BI CHEATSHEET


DAX

What is DAX? Calculated Columns Calculation contexts Calcuation Groups Hierarchy


› They are very similar to Calculated members from MDX. In › DAX itself has no capability within the hierarchy to
“ Data Analysis Expressions (DAX) is a › They behave like any other column in the table. › All calculations are evaluated on a base basis some Power BI, it is not possible to create them directly in the automatically convert your calculations to parent or child
Instead of coming from a data source, they are context that the environment brings to the Desktop application environment, but an External Tool
library of functions and operators created through a DAX expression evaluated based on calculation. (Evaluation context)
levels. Therefore, each level must Prepare Your Measures,
Tabular Editor is required. which are then displayed based on the ISINSCOPE function.
combined to create formulas and the current context line, and we cannot get values ​of › Context Filter - › This is a set of Calculation Items grouped according to their She tests which level to go just evaluating. Evaluation takes
The following calculation calculates purpose and whose purpose is to prepare an expression,
expressions “ another row directly.
the profit forindividual sales.
place from the bottom to the top level.
› Import mode. Their evaluation and storage is in progress which can be used for different input measures, so it doesn‘t › The native data model used by DAX does not directly support
when processing the model. have to write the same expression multiple times. To where its parent/child hierarchy. On the other hand, DAX contains
Introduction to DAX
Revenue =
› DirectQuery mode. They are evaluated at runtime, which may SUMX( Trades, she would be, but the input measure is placed functions that can convert this hierarchy to separate columns.
slow down the model. Trades[Quantity]* SELECTEDMEASURE(). › PATH - It accepts two parameters, where the first parameter is the key ID
Trades[UnitPrice] Example: column tables. The second parameter is the column that holds the parent
› Where to find Profit = Trades[Quantity]*Trades[UnitPrice] ) ID of the row. The result of this function then looks like this: 1|2|3|4
› Power BI, Power Pivot for Excel, Microsoft Analysis Services CALCULATE ( SELECTEDMEASURE(), Syntax: PATH( <ID_columnName>, <parent_columnName> )
› Purpose If I place this calculation in a table Trades[Dealer] = 1) › PATHITEM – Returns a specific item based on the specified position
› DAX was created to enumerate formulas across the data Measures without a Country column, then the
result will be 5,784,491.77. With this column, we get "Total"
› From a visual point of view, the Calculation Group looks like a
from the string, resulting from the PATH function. Positions are counted
from left to right. The inverted view uses the PATHITEMREVERSE function.
model, where the data is stored in the form of tables, which table with just two columns, "Name," "Ordinal," and rows Syntax: PATHITEM( <path>, <position>[, <type>] )
can be linked together through the sessions. They may have a › They do not compare row-based calculations, but they the same as the previous calculation. Still, the individual
that indicate the individual Calculation Items. › PATHILENGTH – Returns the number of parent elements to the specified
cardinality of either 1: 1, 1: N, or M: N and your direction, perform aggregation of row-based values input contexts that records provide us with a FILTER context that filters in item in given the PATH result, including itself.
› In addition to facilitating the reusability of the prepared
which decides which table filters which. These sessions are the environment passes to the calculation. Because of this, calculating the input the SUMX function's input. They behave Syntax: PATHLENGTH( <path> )
expressions also provide the ability to modify the output
either active or inactive. The active session is automatically there can be no pre-counting result. It must be evaluated the same way, for example, AXES in the chart. › PATHCONTAINS – Returns true if the specified item is specified exists in
format of individual calculations. Within this section, “Format the specified PATH path.
and participates in the calculation. The inactive is involved in only at the moment when Measure is called. › The filter context is can be adjusted with various functions,
String Expression ”often uses the DAX function Syntax: PATHCONTAINS( <path>, <item> )
this when it is activated, for example, by a function › The condition is that they must always be linked to the table such as FILTER,ALL, ALLSELECTED
SELECTEDMEASUREFORMATSTRING(), which returns a format
USERELATIONSHIP() to store their code, which is possible at any time alter. › Row context - Unlike the previous one, this context does not
DAX Queries
string associated with the Measures being evaluated.
Because their calculation is no longer directly dependent, it is filter the table. It is used to iterate over tables and evaluate
common practice to have one separate Measure Table, which values columns. They are typical, but at the same time,
groups all Measures into myself. For clarity, they are specific example calculated columns that are calculated from
Example: › The basic building block of DAX queries is the expression
therefore further divided into folders. data that are valid for the table row being evaluated. In
EVALUATE followed by any expression whose output is a
particular that, manual creation is not required when creating
VAR _selectedCurrency = SELECTEDVALUE( Trades[Currency] ) table.
Example of Measure: the line context because DAX makes it. Above the mentioned RETURN Example:
example with the use of SUMX also hides in itself line context.
Basic concepts SalesVolume = SUM (Trades[Quantity]) SELECTEDMEASUREFORMATSTRING() & „ “ & _selectedCurrency
Because SUMX is the function for that specified, the table in EVALUATE
the first argument performs an iterative pass and evaluates › In Power BI, they can all be evaluated pre-prepared items, or ALL (Trades[Dealer] )
it is possible, for
› Constructs and their notation
› Table – ‘Table‘
Variables the calculation line by line. The line context is possible to use
even nested. Or, for each row of the table, evaluates each row example, to use the › The EVALUATE statement can be divided into three primary
cross-section to define sections. Each section has its specific purpose and its
› Column – [Column] -> ‘Table‘[Column] of a different table.
items that are currently introductory word.
› Measure – [NameOfMeasure] › Variables in DAX calculations allow avoiding › Definition – It always starts with the word DEFINE. This section defines
being evaluated
repeated recalculations of the same procedure.
Calculate type function
› Comments local entities such as tables, columns, variables, and measures. There can
› Sometimes, however, it is be one section definition for an entire query, although a query can contain
› Single-line (CTRL + ´) – // or -- Which might look like this: necessary to enable the evaluation of Calculation Items only multiple EVALUATEs
› Multi-line – /* */ NumberSort = for Specific Measures. In that case, it is possible to use the › Query – It always starts with the word EVALUATE. This section contains
› CALCULATE, and CALCULATETABLE are functions that can the table expression to evaluate and return as a result.
› Data types VAR _selectedNumber = ISSELECTEDMEASURE() function, whose output is a value of type
SELECTEDVALUE( Table[Number] ) programmatically set the context filter. In addition to this › Result – This is a section that is optional and starts with the word ORDER
› INTEGER boolean or the SELECTEDMEASURENAME() function that returns
RETURN feature converts any existing line context to a context filter. BY. It contains the possibility to sort the result based on the inserted
› DECIMAL the name of the currently inserted measure as a string. inputs.
IF( _selectedNumber < 4, _selectedNumber, 5 ) › Calculate and Calculatetable syntax:
› CURRENCY CALCULATE / CALCULATETABLE ( Example:
› DATETIME
› BOOLEAN
› Their declaration uses the word VAR after followed
)
<expression> [, <filter1> [, … ]]
Conditions DEFINE
by the name "=" and the expression. The first using VAR _tax = 0.79
› STRING › The section filter within the Calculate expression is NOT of
the word VAR creates a section for DAX where type boolean but Table type. Nevertheless, boolean can be
› Like most languages, DAX uses the IF function. Within this EVALUATE
› VARIANT (not implemented in Power BI) language, it is defined by syntax: ADDCOLUMNS(
› BINARY possible declare such variables 1 to X. Individual used as an argument. Trades,
IF ( <logical_test>, <value_if_true>[, <value_if_false>])
variables always require a comment for their › Example of using the calculate function in a cumulative Where false, the branch is optional. The IF function explicitly
„AdjustedpProfit“,
› DAX can work very well with some types as well combined as ( Trades[Quantity] * Trades[UnitPrice] ) * _tax
declaration VAR before setting the name. To end this calculation the sum of sales for the last 12 months: evaluates only a branch that is based on the result of a logical
if it were the same type. If so, for example, the DATETIME and CALCULATE (
)
INTEGER data types are supported operator "+" then it is section, the word RETURN that it defines is a SUM ( Trades[Quantity] ), test relevant. ORDER BY [AdjustedpProfit]
possible to use them together. necessary return point for calculations. DATESINPERIOD( › If both branches need to be evaluated, then there is a function › This type of notation is used, for example, in DAX Studio
› Variables are local only. DateKey[Date], IF.EAGER() whose syntax is the same as IF itself but (daxstudio.org). It is a publicly available tool that provides free
Example: DATETIME ( [Date] ) + INTEGER ( 1 ) = DATETIME ( [Date] + 1) MAX ( DateKey[Date] ),
› If there is a variable in the formula that is not used evaluates as: access to query validation, code debugging, and query
-1, VAR _value_if_true = <value_if_true>
to get the result, this variable does not evaluate. performance measurement.
Operators
YEAR VAR _value_if_false = <value_if_false>
)) › DAX studio has the ability to connect directly to
(Lazy Evaluation) RETURN
IF (<logical_test>, _value_if_true, _value_if_false) Analysis Services, Power BI a Power Pivot for Excel
› Evaluation of variables is performed based on › Syntax Sugar: › IF has an alternative as IFERROR. Evaluates the expression
› Arithmetic { + , - , / , * , ^ } evaluated context instead of the context in which › [TradeVolume](Trades[Dealer] = 1)
Recommended sources
and return the output from the <value_if_error> branch only if
› Comparative { = , == , > , < , >= , <= , <> } the variable is used directly. Within one, The = the expression returns an error. Otherwise, it returns the
CALCULATE ( [TradeVolume], Trades[Dealer] = 1)
› Joining text { & } expression can be multiple VAR / RETURN sections value of the expression itself.
= › Marco Russo & Alberto Ferrari
› Logic { && , II , IN, NOT } that always serve to evaluate the currently CALCULATE ( [TradeVolume], FILTER ( › DAX supports concatenation of conditions, both using
› Daxpatterns.com
› Prioritization { ( , ) } evaluated context. ALL (Trades[Dealer] ) , submerged ones IF, so thanks to the SWITCH function. It
› dax.guide
› They can store both the value and the whole table Trades[Dealer] = 1) ) evaluates the expression against the list values ​and returns one › The Definitive Guide to DAX
of several possible result expressions.

JAK NA POWER BI CHEATSHEET


POWER QUERY

What is Power Query? Data values let expression Custom function Syntax Sugar
Each value type is associated with a literal syntax, a set of values The expression let is used to capture the value from an Example of custom function entries: › Each is essentially a syntactic abbreviation for declaring non-
“An IDE for M development“ ​of that type, a set of operators defined above that set of values, intermediate calculation in a named variable. These named (x, y) => Number.From(x) + Number.From(y) type functions, using a single formal parameter named.
and an internal type attributed to the newly created values. variables are local in scope to the `let` expression. The Therefore, the following notations are semantically
equivalent:
Components
› Null – null construction of the term let looks like this: (x) =>
› Logical – true, false let let let
› Number – 1, 2, 3, ... name_of_variable = <expression>, out = Number.From(x) + Source = ...,
› Ribbon – A ribbon containing settings and pre-built features by Power › Time – #time(HH,MM,SS) Number.From(Date.From(DateTime.LocalNow()))
addColumn = Table.AddColumn(Source, „NewName“, each [field1] + 1)
Query itself rewrites in M ​language for user convenience. returnVariable = <function>(name_of_variable) in
› Date – #date(yyyy,mm,ss) in in
› Queries – simply a named M expression. Queries can be moved into addColumn
› DateTime – #datetime(yyyy,mm,dd,HH,MM,SS) returnVariable out ------------------------------------------------------------------------------------------------------------------------------------------------------------------
groups
› DateTimeZone – let
› Primitive – A primitive value is a single-part value, such as a number, When it is evaluated, the following always applies: The input argumets to the functions are of two types: Source = ...,
#datetimezone(yyyy,mm,dd,HH,MM,SS, 9,00)
logical, date, text, or null. A null value can be used to indicate the absence › Required – All commonly written argumets in (). Without add1ToField1 = (_) => [field1] + 1,
of any data. › Duration – #duration(DD,HH,MM,SS) › Expressions in variables define a new range containing
these argumets, the function cannot be called. addColumn(Source,“NewName“,add1ToField1)
› List – The list is an ordered sequence of values. M supports endless lists. › Text – “text“ identifiers from the production of the list of variables and must in
› Optional – Such a parameter may or may not be to function to
Lists define the characters “{“ and “}“ indicate the beginning and the end of › Binary – #binary(“link“) be present when evaluating terms within a list variables. The
enter. Mark the parameter as optional by placing text before The second piece of syntax sugar is that bare square brackets are syntax
the list. › List – {1, 2, 3} expressions in the list of variables are they can refer to each
the argument name “Optional“. For example (optional x). If it sugar for field access of a Record named `_`.
› Record – A record is a set of fields, where the field is a pair of which form › Record – [ A = 1, B = 2 ] other
the name and value. The name is a text value that is in the field record does not happen fulfillment of an optional argument, so be the
unique.
› Table – A table is a set of values ​arranged in named columns and rows.
› Table – #table({columns},{{first row contenct},{}…})*
› Function – (x) => x + 1
› All variables must be evaluated before the term let is evaluated.
› If expressions in variables are not available, let will not be
same for for calculation purposes, but its value will be null. Query Folding
Optional arguments must come after required arguments.
Table can be operated on as if it is a list of records, or as if it is a record of
› Type – type { number }, type table [ A = any, B = text ] evaluated
* The index of the first row of the table is the same as for the records in sheet 0 › Errors that occur during query evaluation propagate as an error As the name implies, it is about composing. Specifically, the
lists. Table[Field]` (field reference syntax for records) returns a list of values in Arguments can be annotated with `as <type>` to indicate
that field. `Table{i}` (list index access syntax) returns a record representing a to other linked queries. steps in Power Query are composed into a single query, which
required type of the argument. The function will throw a type
row of the table. is then implemented against the data source. Data sources
› Function – A function is a value that when called using arguments creates a Operators error if called with arguments of the wrong type. Functions can
that supports Query folding are resources that support the
new value. Functions are written by listing the function argumets in
parentheses, followed by the transition symbol “=>“ and the expression
Conditions also have annotated return of them. This annotation is provided
as:
concept of query languages as relational database sources.
There are several operators within the M language, but not every This means that, for example, a CSV or XML file as a flat file
defining the function. This expression usually refers to argumets by (x as number, y as text) as logical => <expression>
name. There are also functions without argumets.
operator can be used for all types of values. Even in Power Query, there is an “If“ expression, which, based with data will definitely not be supported by Query Folding.
› Parameter – The parameter stores a value that can be used for › Primary operators on the inserted condition, decides whether the result will be a The return of the functions is very different. The output can be a Therefore, the transformation does not have to take place
transformations. In addition to the name of the parameter and the value it › (x) – Parenthesized expression true-expression or a false-expression. sheet, a table, one value but also other functions. This means until after the data is loaded, but it is possible to get the data
stores, it also has other properties that provide metadata. The undeniable › x[i] – Field Reference. Return value from record, list of values that one function can produce another function. Such a function ready immediately. Unfortunately, not every source supports
Syntactic form of If expression:
advantage of the parameter is that it can be changed from the Power BI from table. is written as follows: this feature.
Service environment without the need for direct intervention in the data if <predicate> then < true-expression > else < false-expression >
› x{i} – Item access. Return value from list, record from table. › Valid functions
set. Syntax of parameter is as regular query only thing that is special is that “else is required in M's conditional expression “ let first = (x)=> () => let out = {1..x} in out in first
“Placing the “?“ Character after the operator returns null if the › Remove, Rename columns
the metadata follows a specific format.
index is not in the list “ Condition entry: When evaluating functions, it holds that: › Row filtering
› Formula Bar – Displays the currently loaded step and allows you to edit › Grouping, summarizing, pivot and unpivot
› x(…) – Function invocation If x > 2 then 1 else 0 › Errors caused by evaluating expressions in a list of
it.To be able to see formula bar, It has to be enabled in the ribbon menu › Merge and extract data from queries
inside View category. › {1 .. 10} – Automatic list creation from 1 to 10 If [Month] > [Fiscal_Month] then true else false expressions or in a function expression will propagate › Connect queries based on the same data source
› Query settings – Settings that include the ability to edit the name and › … – Not implemented If expression is the only conditional in M. If you have multiple further either as a failure or as an “Error“ value › Add custom columns with simple logic
description of the query. It also contains an overview of all currently applied › Mathematical operators – +, -, *, / predicates to test, you must chain together like: › The number of arguments created from the argument › Invalid functions
steps. Applied Steps are the variables defined in a let expression and they › Comparative operators › Merge queries based on different data sources
if <predicate> list must be compatible with the formal argumets of
are represented by varaibles names. › Adding columns with Index
› > , >= – Greater than, greater than or equal to then < true-expression > the function, otherwise an error will occur with reason
› Data preview – A component that displays a preview of the data in the › Change the data type of a column
currently selected transformation step.
› < , <= – Less than, less than or equal to else if <predicate> code “Expression.Error“
› = , <> – is equal, is not equal. Equal returns true even for then < false-true-expression >
DEMO
› Status bar – This is the bar located at the bottom of the screen. The row
contains information about the approximate state of the rows, columns,
and time the data was last reviewed. In addition to this information, there is
null = null
› Logical operators
else < false-false-expression >
When evaluating the conditions, the following applies:
Recursive functions
profiling source information for the columns. Here it is possible to switch › and – short-circuiting conjunction › Operators can be combined. For example, as follows:
the profiling from 1000 rows to the entire data set. › or – short-circuiting disjunction › If the value created by evaluating the if a condition is not a For recursive functions is necessary to use the character “@“
logical value, then an error with the reason code
› LastStep[Year]{[ID]}
› not – logical negation which refers to the function within its calculation. A typical
*This means that you can get the
Functions in Power Query › Type operators “Expression.Error„ is raised recursive function is the factorial. The function for the factorial
value from another step based on the index of the column
› as – Is compatible nullable-primitive type or error › A true-expression is evaluated only if the if condition can be written as follows:
Knowledge of functions is your best helper when working with › is – Test if compatible nullable-primitive type evaluates to true. Otherwise, false-expression is evaluated. let › Production of a DateKey dimension goes like this:
a functional language such as M. Functions are called with › Metadata - The word meta assigns metadata to a value. › If expressions in variables are not available, they must not be Factorial = (x) => #table(
parentheses. Example of assigning metadata to variable x: evaluated if x = 0 then 1 else x * @Factorial(x - 1), type table [Date=date, Day=Int64.Type, Month=Int64.Type,
› Shared – Is a keyword that loads all functions “x meta y“ or “x meta [name = x, value = 123,…]“ › The error that occurred during the evaluation of the condition Result = Factorial(3) MonthName=text, Year=Int64.Type,Quarter=Int64.Type],
(including help and example) and enumerators in Within Power Query, the priority of the operators applies, so for example will spread further either in the form of a failure of the entire in List.Transform(
result set. The call of function is made inside empty “X + Y * Z“ will be evaluated as “X + (Y * Z)“ query or “Error“ value in the record. Result // = 6 List.Dates(start_date, (start_date-endd_ate),
query using by = # shared #duration(1, 0, 0 ,0)),
each {_, Date.Day(_), Date.Month(_),
Comments The expression try… otherwise Each Date.MonthName(_), Date.Year(_), Date.QuarterOfYear(_)}
))
Functions can be divided into two categories: Capturing errors is possible, for example, using the try Functions can be called against specific arguments. However, if
M language supports two versions of comments:
› Prefabricated – Example: Date.From() expression. An attempt is made to evaluate the expression
Keywords
› Single-line comments – can be created by // before code the function needs to be executed for each record, an entire
› Custom – these are functions that the user himself prepares after the word try. If an error occurs during the evaluation, the sheet, or an entire column in a table, it is necessary to append
for the model by means of the extension of the notation by › Shortcut: CTRL + ´ expression after the word otherwise is applied the word each to the code. As the name implies, for each
„()=> “, where the argumets that will be required for the › Multi-line comments – can be created by /* before code and and, as, each, else, error, false, if, in, is, let, meta, not,
Syntax example: context record, it applies the procedure behind it. Each is never
evaluation of the function can be placed in parentheses. */ after code otherwise, or, section, shared, then, true, try, type, #binary,
try Date.From([textDate]) otherwise null required! It simply makes it easier to define a function in-line
When using multiple argumets, it is necessary to separate › Shortcut: ALT + SHIFT + A #date, #datetime, #datetimezone, #duration, #infinity, #nan,
for functions which require a function as their argument.
them using a delimiter. #sections, #shared, #table, #time

JAK NA POWER BI CHEATSHEET

You might also like