You are on page 1of 2

Business intelligence technologies II

Laboratory work 8 Student:


CALCULATE function continuation

The Power BI tool allows you to collect multiple data sources, create complex data models, and interactively visualize results. This
tool is designed for business users, people without serious IT education. The proposed tool capabilities are intuitively deployed and
most actions can be met with the Drag & Drop principle.
An important part of this tool is the programming language of the DAX (Data Analysis eXpressions). With this language, you can
create multiple-level calculations by pulling out the maximum benefit of the proposed data. As any programming language, including
The DAX is highly structured and formalized. It has its own written terms and requirements. The DAX allows three types of
calculations: measurements, columns, tables.

Context: The concept of the DAX language, which describes a rule that the formula must take into account when calculating. Most
common contexts specifies which data from the columns should be used.

Filter context. The most common context used in Power BI. A filter is any value that limits the outcome of a specific calculation. A
basic report that shows sales by regions uses regions as a filter criteria for the calculation "Sales". When creating a Power BI report
each visual becomes a filter and as such also participates in the filter context that affects the calculation result. Filter context determines
which part of a table to use in a calculation. In Excel this would limit the amount of rows in the original table and then perform the
calculation on the remaining rows that match the filter criteria. Filter criteria can come from multiple tables if there are relationships
between them.

Query context – a combination of row and filter context. The most import context to understand when working with DAX and what
determines the end result for calculations.

CALCULATE() function is the only DAX function that can modify the query context. Change the existing rules or add new ones.

Lesson plan
This week we learn the CALCULATE function. We’ll try to understand how it works and try to find use cases.

Task 1
Create relationships between table. Create a place to store measure. Create a dimension table for countries.

Task 2 ( 1 point ) Create multiple reports with specific


measures:
1. Weight % by countries.
2. Add an option to filter by container category.
3. Add an option to filter by client group.
4. Weight split % by countries and loading ports. The sum of port % for each country be 100%.
5. Total weight for clients that have more than 100 transactions.
6. Weight % for clients that have more than 100 transactions by loading ports.

Task 3 ( +1 point )
Think about visualization in each report. Try a number of visuals and the capabilities they provide. Think about the general visual idea.
Things like readability (letter size, readable content), placement of visuals and technical capabilities (buttons, tooltips etc.) will be the
main points that determine if the submission gets the extra point for formatting.

Task 4 ( +1 point )
Create a report for each client groups weight % comparison. You have to compare groups weight for the clients from the selected
country agaisnt the total weight. Solve this task using two solutions – one with REMOVEFILTERS and the other with TREATAS.

30.03.2022 1 Otto Jānis Jansons


CARGO
Country code in system: 11
CLIENT - Sweden, 12
SELSKAB Country code in system: 11 - Sweden, - Norway, 13 - Finland, 27 -
12 SELSKAB Estonia, 38 - Lithuania

KUNDENR Internal client code to link BOOK_NR Unique number for each Bill
of Lading in
NAVN Client Name
VAREPOST_NR Row count on Container Nr
level
CONT_ANT Units
CONT_TYPE
CONT_NR
BRUTTO
TARA
TRP_MADE1 Full or Empty (FCL- full,
MTY- empty)
SHORT_DESC Commodity short
description

BOOK

Country code in system: 11 - Sweden, 12 - Norway, 13


SELSKAB
- Finland, 27 - Estonia, 38 - Lithuania
BOOK_NR Unique number for each Bill of Lading in system
AFDELING Direction 010-Import and 020 - Export
SAGSNR File Nr for each vessel and voayege (one file could
SKIBS_NAVN Vessel Name
REJSE_NR Vessel Voyage
AFG_ZONE Port of Loading code
AFG_BY Port of Loading full name
AFG_DATO Sailing date
ANK_ZONE Port of discharge code
ANK_BY Port of dischrage full name
ANK_DATO Arrival date
PORT_TRAN STranshipment port
KUNDE Client code
BET_KODE Paiment terms: P-prepaid, C-collect and E - Elswhere
Booking status: U - Printed, I - Open, L - Closed, P
STAT
-
SPECIAL_CO NContract type with client: Q - quatation, T - tariff, S -
CREATION_D Date when booking was created
CREATED_BY User code who created booking
GVA_AFDELI Trade (is defined by port of discharge)
OCEAN_AFD Codes for trades

30.03.2022 2 Otto Jānis Jansons

You might also like