Oracle DBA Tutorial | Learn Oracle DBA with Examples


Oracle Database administrator :

Before getting deep into Oracle database administrators, let us know about databases. A database usually refers to the collection of the information which will be represented in an organized and structured format. All the databases can be efficiently updated, retrieved, and analyzed based on the requirements. A notepad or Excel might not be capable of handling large volumes of data, files and users. Also, restoration of data, backup and extraction of the data is not easily possible using these applications.

To overcome these limitations, oracle has come up with an Oracle database. Oracle database is also called Oracle RDBMS or Oracle. Oracle DBA is referred to as a relational database management system whose primary focus is to store, manage and retrieve the information to ensure that the performance levels are high and efficient.

Oracle database administrator is not a single person but referred to as a group of specialists. Oracle DBA works on a grid-based architecture, and it is also one of the first-ever databases that are flexible to work with enterprise grid computing. An Oracle database administrator is responsible for administering the Oracle database server. Every database requires a database administrator to manage and administer it. As we handle large volumes of data and users, a single person cannot control the whole of the data management. Hence there will be a group of database administrators who are responsible for sharing their responsibilities and make sure tasks are accomplished.

Oracle database administrator is the one who is responsible for the organization, management, and integration of the company’s data which will be represented in large volumes. There are many different roles, responsibilities, job titles in DBA which will be varying wildly. A database administrator is involved in applying the knowledge of the database management system to define, create, maintain, backup, and secure the organizational data.

The primary responsibility of the database administrator is to ensure that authenticated users have access to the data that they need whenever they need to perform any task. A database administrator should also have the problem-solving capability and have expertise on the relevant databases and technologies where he will be able to communicate effectively with the techies and non-techies in the organization. The database administrators also work closely with the other different departments like Business Analyst and help in developing the database that supports the business needs and helps in keeping the database running smoothly and efficiently in a fast way.

If job security is one of the essential aspects for you, and this is the right time to become a database administrator. As per the surveys conducted, it is analyzed that there will be 11% of growth in the database administrator jobs by the year 2026. This leads to an increase of 7 percent on an average for all the occupations.

Responsibilities of Oracle database administrator:

A Database administrator or a DBA is responsible for managing and maintaining complex databases as organizations hold large volumes of databases. Every organization ensures to review and keep track of the commerce and the other activities, which help in analyzing the future of the organization.

In short, a database administration is one of the recording fields, which helps you develop your career effectively and efficiently.

DBA is responsible for performing some tasks that are purely related to the data. Here are some of the roles and responsibilities a database administrator would undergo.

1. Database administrator is the one who is responsible for the installation and up-gradation of the Oracle server and the respective application tools.

2. They are responsible for creating the primary database storage structures, which are called tablespaces after the designing of the application has been completed by the application developers.

3. A dba is also involved in monitoring and optimizing the performance of the database, controlling the access users to the database, ensuring that the compliance values are met within the Oracle license agreement.

4. He is also responsible for modifying the database structures whenever they need based on the information that is given by the application developers.

5. DBA is involved in creating the primary data storage structures, direct objects like table views indexes, involved in allocating the storage system and also some and analyzing and planning the future storage requirements that are required for the database.

6. A database administrator also needs to ensure that they are ready for the backup and recovery of the database information, restoring the database, maintaining the archived data on tape, enrolling the users and maintaining the system security by giving them access only to the authenticated users, etc.

7. Database administrators are also responsible for contacting the Oracle Corporation whenever they need support from the technical support teams.

                                                 Become a Oracle Primavera Expert With HKR. Join Oracle Primavera Training!

Oracle Database Administrator Certification Training

  • Master Your Craft
  • Lifetime LMS & Faculty Access
  • 24/7 online expert support
  • Real-world & Project Based Learning

Features of Oracle database:

Oracle database is referred to as a cross-platform helps in performing the various tasks, running on the various hardware across different operating systems like Linux, Windows Server, and other distributions of Linux/GNU.

  • Oracle database is also said to be an ACID compliant, ACID-compliant database that is responsible for maintaining the data integration and reliability of data.
  • Oracle database also comprises its networking stack that helps in allowing the applications from different platforms to communicate with Oracle database smoothly.
  • Oracle is the database that it is committed to many available technologies, by providing its extensible support from the late 1990s.

Oracle database also has the structural features which are briefly explained below:

1. Partitioning: Oracle database has come up with the partitioning features which is referred to as a high-performance feature that allows you to divide the last table into different small pieces, allowing you to store each small piece across other storage devices.

2. Logical data structure: Oracle uses the logical data structure where it is stored the data for interaction with the database without actually knowing that the information is stored physically.

3. Data dictionary: Data dictionary is one of the features in the Oracle database that consists of the internal tables and view which help in providing their support to administer the Oracle database more effectively and efficiently.

4. Memory caching: Oracle database uses the memory caching architecture, which helps you to scale up the last database that can help you perform at high speed.

5. Clustering: Oracle is providing high support and high availability that is helping the system to be up and running without any interaction of the services even if there is a cluster failure if one or more servers in a cluster fail.

6. Backup and recovery: To ensure the data integrity is maintained, oracle has a powerful tool called recovery Manager, which helps the DBA in performing the backups and point in time recoveries.

Oracle database architecture:

Oracle database maintenance and architecture includes three main components or categories. They are represented below:

1. Shared memory
2. System support infrastructure
3. Operating system files

Let me give a brief explanation about every component in the Oracle database architecture.

Shared memory:

Shared Memory is referred to as section of the host server memory, which is responsible for the passing the data and application code is stored executed.

Shared memory is often referred to as a Random Access Memory in the architecture of Oracle. Most of the adopters of Oracle Technology will make use of the words cal database and instance synonymously. However, there is a difference between both of them.

A database is referred to as the assortment of the files which are used to store the data and also a handful of work of files that help in the facilitation of the application access.

An instance is referred to as a segment of the shared memory which is providing its extensive support to the process, that also has the capability for applications to work with the data that is present in the database. Once shared memory is started, there are different areas of the shared memory that play a significant role in the database management activities.

The System Global Area, or SGA, comprises the data and also controls information from a single database instance.

The Program Global Area or PGA is referred to as a part of memory that is allocated to a 12c instance. The PGA memory is not shared memory like the SGA memory. The page contains the data and the control information that is specific to the server processes and is not considered as an instance as a whole.

The user Global Area or UGA is referred to as a memory that is associated with each user session.
UGA is also referred to as one of the most important components among the four main memory components available. It is not possible to get the details of each of these components.

Let me give you an overview of the shared memory components of a 12c database.

Auto memory management:

Auto memory management in a 12c database refers to the maximum amount of memory that is used which is defined. The instant is also responsible for the self-management of the size of the assortment of the SG components. The auto memory management approach is used by Oracle mostly and is also referred to as the automatically shared memory management (ASMM).

Manual memory management:

In manual memory management, the administrator is responsible for specifying the fixed size of the components that will make up the SGA. The size of each component is specified in the system parameter file.

System support processes:

System support processes are initiated automatically once the Oracle instance is started. Each process has its importance and performance in the management of the application interaction with the data available.

Below are the set of background processes that support the database.

1. Ckpt: The checkpoint process will help in synchronizing the control file in the data file headers with the available checkpoint information. Apart from this, it also signals the database to write a process that it is time for it to perform the activities that need to be completed.

2. Dbwo: The database writer process is involved in copying the contents of the database offers in the memory to the appropriate database files as per the requirements.

3. Lreg: The listener registration process is responsible for registering the instance information for the Oracle net listener process. If there is an instance where the listener process is not running during the startup, then Lreg tries to attempt to contact it from time to time basis and pass relevant information.

4. Mmon: The manageability monitor process is responsible for establishing the association with the fact that are related to the auto is an automated workload repository.

5. Pmon: The manageability monitor light process also plays an important role in the active session history module. The active session history samples the database activity every second, all the rate of that is trapped can be used for tracking performance issues.

6. Reco: The process monitor is considered as a gatekeeper of the Other server processes, responsible for monitoring all the background processes. It is also involved in performing the recovery activities when the situations come up like the processes end abruptly. It is also responsible for performing resource cleanup activities when required online sessions.

7. smon: The system monitor process is responsible for handling the instance cleanup tasks like a recovery at the startup time if any inconsistencies would cause instance failure.

Operating system files: Operating system files are referred to the suit of fewer than 10 files which have their own individual roles as a database runs.

Below is a list of the operating system files and have their own prominence.

1. Control file: The control file is responsible for managing the metadata of the running instance. There should be at least a minimum of to control files.

2. System parameter: System parameter file includes a list of the parameters and the values that have to be used when the instance is started.

3. Password file: Password file plays an important role in determining who is allowed to initiate the connections to the database in order to perform certain activities and ensure security.

4. System tablespace: If system tablespace is referred to as the heart of a 12c database that comprises the data dictionary as well as the host tombstone information that is relevant to the database activities.

5. Undo tablespace: Undo tablespace is referred to as a player in the Oracle’s read consistent model that contains information required to roll back non committed changes to the data.

6. Temp tablespace: The temp tablespace is referred to as a work area that is used for the Intermediate result sets assembling during the query processing and also to support the sort activities.

7. Online redo: Online redo is referred to as a transaction log that comprises the record or the copy of all the activities that have been happening in the 12c database.

8. Tools tablespace: The tools tablespace is referred to as the user-defined tablespace that is used to house non-system related data.

Become a Oracle Performance Tuning Expert With HKR. Join Oracle Performance Tuning Training !

others, oracle-dba-tutorial-description-0, others, oracle-dba-tutorial-description-1

Subscribe to our YouTube channel to get new updates..!

Terminologies used in Oracle DBA:

You need to understand the basic terminologies that are used in Oracle DBA. We have collected some of the basic terms that are most commonly used in Oracle DBA in this tutorial, as explained below:

Instance: An instance is referred to as the background process and the memory structure that is specifically used to retrieve data from the database.

Process: Process is often referred to as the task or a job that needs to be performed. Oracle comprises two different types of processes. They are Oracle processes and user processes. The operating system commands are not required to be used to interact with the database.

Buffer cache: The buffer cache is referred to as the SGA component that is responsible for storing the data being customized or query and acts as a buffer. The buffer cache is responsible for storing the most recently or frequently used data in the memory to improve the performance. The user processes that are connected to the database will have or share access to it.

Shared pool: Shared pool is responsible for capturing information that is required to be shared with the users. Shared pools include SQL statements, stored procedures, etc. that can be used for reusability and fast access.

Large pool: Large pool is the options area that often provides or offers in memory allocation for extensive processes. It includes oracle backup and recovery operations.

Redo log buffer: The redo log buffer is used to maintain the changes that are made in the database. The redo log files can be overwritten and will run in a circular motion. The redo log helps in recovering the instance whenever there is a failure that occurs. The redo log buffer helps in improving the performance and functionality of the database system.

Locks: Locks are used for controlling the simultaneous access to different data resources.

Database objects in Oracle:

1. Tables: Tables are referred to as common objects that are considered as an integral part of the database. Once the table creation is completed, and the data should be stored by following some of the basic rules like data types, values etc. The table includes all the important rules, and it is easy to access and also compatible to be modified with simple SQL commands.

2. Views: Whenever the database administrator would like to limit the access to the data, a view should come into the picture. There are different types of views of data that can be defined based on the company and user requirements.

Let us take an example where you would like to share the Limited amount of information with the other organization, and then you need to master the rest of the information with proper SQL commands.

Views are introduced to ensure the security aspect is maintained.

3. Synonyms: Synonyms here referred to the process of allowing the users referring to the different objects that are stored somewhere else in the same or different database. These objects are also called handy objects which can be used with the alternative names in the table, and you can also set a pointer to the real table.

Synonyms are referred to as a main memory management technique which some of the objects can be reused and it helps in the Optimization of the overall storage space for the database objects. The database programmers mostly use this concept, and it is used since decades which would increase the throughput of the application code.

4. Stored objects: Store objects are those objects that help in promoting the encapsulation of the code which can be Run either implicitly or explicitly to perform the predetermined task. The most important aspect that needs to be focused on is the usability of the Stored objects which can be reused again and again whenever there is some action that needs to be done. Stored objects help in maintaining consistent performance and also secure the processing together. This object can be divided into functions, procedures, packages which are used to declare the variables, constants, and cursors for exceptional handling.

Benefits of Oracle database:

Oracle has come up with a set of advantages that would help in improving the performance and efficiency, also involved in meeting the client requirements efficiently. Let us have a quick review of the benefits of Oracle database and its help to the Oracle database administrators.

1. Performance: Oracle has come up with the principles and methodologies that are helping in achieving higher performance than any other databases. In Oracle, we can implement the performance tuning in the database, leading to faster retrieval of the data and also altering the data, further leading to the improvement in the query execution time.

2. Editions: Different editions are offered by Oracle. Oracle provides benefits to the users to purchase the edition as per their application requirements and the client requirements. The additions can be updating seamlessly if there is a change in the requirements in the future. The express edition is absolutely free, and you can use it if you want to give a trial and work on the Oracle database to get some hands-on experience on Oracle.

3. Clusters: Oracle uses the real application clusters which help in improving the high data availability systems. The database that contains the real application clusters will have many benefits over the traditional database servers like load balancing, flexibility to increase the processing capacity, scaling up the database over multiple instances, and data redundancy and availability.

4. Multiple databases: Multiple databases involve the management of multiple database instances on a single server. Oracle uses instance casing method to manage the CPU allocations on a server that is running the database instances.

5. Failure recovery: Oracle includes a recovery manager, which is one of the essential features in the Oracle database. The recovery manager has the capability to recover and restore the database files during the outages and downtimes.Users are also allowed to use the user-managed recovery which is supported by Oracle.

6.PL/SQL: Database also provides extensible support to PL for performing procedural programming.

Drawbacks of Oracle database:

There are some set of disadvantages or limitations in the Oracle database. They are explained below:

1. Management of the structure: The management of the structure in Oracle tends to be complex sometimes and seems to be difficult to manage for performing some activities. It is highly recommended to use the basic version and configured with minimal customization.

2. Incompatibility and complexity: Oracle processes some incompatibility and complexity, which is considered as a limitation in terms of time, character and data Syntax sensitivity.

3. Price: Most of the time, there is no price for a specific budget for Oracle licence. Any changes over time, it depends on the change of a policy, updates, patches by the organization.

Oracle Database Administrator Certification Training

Weekday / Weekend Batches

Conclusion:

Oracle database is one of the most commonly used databases in the organization.There is a high need for the database administrators who are involved in implementing and performing the database operations efficiently by meeting the offline customer requirements.Most of the organizations are looking forward to individuals who have the expertise to be a database administrator. Oracle database administrator is one of the prominent roles in the database management field,which is a rewarding field in the current times.Hence,I recommend you to go through this tutorial, also get trained and certified in Oracle to attain a prosperous career in the near coming future.

Related Article:

Oracle Apps DBA Training



Source link

Leave a Reply

Subscribe to Our Newsletter

Get our latest articles delivered straight to your inbox. No spam, we promise.

Recent Reviews


What is the Power BI Matrix?

The visual of the matrix is identical to that of a table. The data in a table is flat, which ensures that duplicate values are shown and not aggregated. A matrix supports a stepped structure, which makes it easier to view data meaningfully across multiple dimensions. The matrix aggregates the data for you and helps you to dig down into it. 

Power BI Matrix

Why Power BI Matrix?

The matrix aggregates the data automatically and allows for drill-down. In Power BI Desktop reports, you can create matrix visuals and highlight elements inside the matrix with other visuals on the same report page. You may, for instance, cross-highlight rows, columns, and even individual cells. Individual cells, as well as different cell selections, can be copied and pasted into other applications.

Understanding the Data: 

We will use the Matrix visual as an example to illustrate some interesting techniques. The example data is a list of numbers drawn from the Maltese lotto. Each record is one number from a drawing, and each drawing has five records, one for each of the five numbers.The numbers for each drawing can be displayed as a single line using the Matrix visualisation, as shown in this figure. 

single line using the Matrix visualisation

The goal is to have a slicer that filters rows based on the number or numbers selected. If you choose 5 and 10, for example, the rows that contain those numbers will be displayed:

 numbers selected

You can also use conditional formatting to make the selected numbers glow in a colour of your choosing.

 conditional formatting

Each row in the table represents a single number drawn in a single lotto drawing. Since each drawing has five numbers, the table includes five records for each drawing. Lotto is the name of the table, and the following fields are the most important in this example:

DrawNo: The number of the drawing

DrawOrder: The order of the drawn number

Number: The drawn number

Begin by creating a new Power BI dashboard and then importing the csv file. You can also use the MatrixSimpleStart.pbix file included in the zip file as a starting point.

Matrix Creation

There are three fields to configure in the Matrix visual: the field for the rows, the field for the columns, and the values’ field. A single drawing with the five numbers should be shown on each line of the visual. As a result, the DrawNo field will be used to aggregate the drawings on each row.

How do you show five records on each line when each drawing has five records, the five drawn numbers? The columns’ title will be decided by the content of the field you select as a column field. The best choice is easy: “DrawOrder”. Each row shows the “DrawNo”. Each column has the “DrawOrder” as a title and will show the drawn “Number” as a value in the column.

Follow a quick sequence of steps to configure the Matrix visual once you’ve opened the file MatrixSampleStart.pbix or imported the csv file. You’ll be working in Report view.

a. Add a “Matrix” visual to the report from the “Visualizations” pane.

Matrix

b. Drag the three fields, “DrawNo”, “DrawOrder”, and “Number”, to the appropriate slots in the “Fields Pane”.

DrawOrder

The Matrix will look like this after you’ve placed all of the fields in the correct spots:

correct spots

c. In the “Visualizations Pane”, with the matrix selected, click the “Format” button and disable the subtotals for rows and columns as they are not needed.

Visualizations Pane

Format

d. While still in the “Format” tab, under the “Style” option, change the style of the matrix. You can choose any available style; I suggest “Bold Header”.

 style of the matrix

Power BI Training

  • Master Your Craft
  • Lifetime LMS & Faculty Access
  • 24/7 online expert support
  • Real-world & Project Based Learning

e. Still in the “Format” tab, change the font size under these three different options: “Row Headers”, “Column Headers”, and “Values”. I like to use 12 as font size.

Row Headers

The completed Matrix should look like this:

 completed Matrix

Creating a Slicer and Filtering the Matrix

Since the matrix includes numbers from lotto drawings, filtering the drawn numbers and only displaying the drawings with the selected drawn numbers is the right choice for a slicer.

There are three possible approaches to create a slicer:

  • Build a slicer based on the table’s original fields (Lotto).
  • Build a slicer based on a new measured table by transforming the original table into a new one using a DAX expression.
  • Make a slicer based on a What-If condition.

Note that DAX is an expression language used in tabular models, such as the Power BI model, to allow for calculations to be done on the model.

The first two options maintain a connection to the original table (Lotto). Although this relationship does not affect the outcome, it does cause a minor bug. The slicer must be placed before the matrix on the page. Some slicer configurations will be unavailable if the slicer is inserted after the matrix. First, the slicer must be inserted.

Creating a Slicer from the Same Table

The simplest way to add a slicer is from a table field. Unfortunately, in this case, it does not quite provide the answer. To see how to add a slicer based on the table, follow these steps:
a. Drop the matrix.
b. In the “Fields Pane”, select the “Number” field in the Lotto table.
c. In the “Visualizations” Pane, change the visual to “Slicer”.

Slicer

d. Change the slicer format to “List” in the slicer style option within the slicer.

slicer style option

e. Select the slicer in the Visualizations Pane and press the “Format” button. Disable the “Single Select” option in the “Selection Control” options to enable multiple number selection.

Format

f. Repeat the steps in the “Create the Matrix” section to recreate the matrix.

Select two numbers in the slicer, such as 5 and 10, and look at the result in the matrix to evaluate this solution. You’ll note two issues:

  • Instead of showing all of the numbers from the chosen draws, the draws are filtered to display only the selected numbers. This isn’t the best outcome for this problem.
  • The multiple choices act as an OR rather than an AND. Only one of the two chosen numbers appears in the drawings.

Create the Matrix

Fixing the Selection

A different approach to this problem is needed to address the range. The model and visual engine in Power BI build the filter automatically, displaying only the selected numbers. To display all of the chosen draws’ numbers, you’ll need to disable the automatic filter and construct a DAX formula to decide which ones should be displayed.

This takes us back to the decision on how to design the slicer: building the slicer directly from the draws table (Lotto) establishes an inevitable relationship. The only slicer option that won’t work is this one. The relationship to the source table (Lotto) can be managed if you construct the slicer from a calculated table or What-If parameter, avoiding the filtering.

You can construct a DAX formula to filter the drawings if the slicer does not directly filter the matrix. The expression would compare the numbers on the current drawing row to the slicer’s chosen numbers to decide whether the row should be displayed.

Next, you’ll see two alternate ways to render the slicer, both of which include the use of a helper table. You have the choice of using either method.

Creating the Slicer – Calculated Table

An essential DAX expression can be used to build this table. A button named “New Table” can be found on the top menu, “Modeling” tab. After you click this button, space expands in which you can type in the DAX expression for this table.

Creating the Slicer – Calculated Table

Call the table “Selector”. The expression is very simple:

Selector = VALUES (Lotto[Number] )

Selector, the newly created table, would be unrelated to the original. The only impact would be the strange visual action that allows the slicer to be generated before the matrix, considering the fact that it was created from Lotto rows.

Lotto rows

Business Intelligence & Analytics, power-bi-matrix-description-10, Business Intelligence & Analytics, power-bi-matrix-description-19

Subscribe to our YouTube channel to get new updates..!

You must perform the following steps if you chose this choice for the “Selector” table:

  1. Drop the slicer.
  2. Drop the matrix.
  3. Create the slicer again using the steps from the “Creating a Slicer from the Same Table” section but use the “Number” field from the “Selector” table.
  4. Create the matrix again.

The slicer will not filter the data at this point. Please keep reading to figure out how to make it sort the matrix.

Creating the Slicer from the What-if Parameter

It would be best to create a “What-if” parameter instead of creating the “Selector” table based on the Lotto table. This is a new table with no relationship to the Lotto table. If you used the table in the previous section to build the Selector, delete it before proceeding.

a. Delete the matrix

b. To open the “What-if Parameter” window, go to the top menu, “Modeling” tab, and press the “Create Parameter” button.

Create Parameter

2. Click “OK” once the properties have been filled in.

DAX Formula

Behind the scenes, the following DAX formula is generated:

Selector = GENERATESERIES ( 1, 99, 1 )

In the Fields pane, you’ll find a new measure:

 

GENERATESERIES

As you can see in the image above, this option varies slightly from the previous one in that the area generated within the the “Selector” table is now called “Selector” rather than Number.

You should rename the “Selector” field to “Number” to make all options the same. It’s not necessary, but if you don’t, the following expressions would need to use Selector[Selector] instead of Selector[Number] to apply to this field.

The steps to rename this field:

  1. Click the ‘…’ (More Options) button in the “Fields” pane, next to the “Selector” field, under the “Selector” table.
  2. In the context menu that appears, select the “Rename” menu item.
  3. Change the name of the area to “Number”.

Follow these steps to complete the slicer

  1. To format the new slicer that will be automatically added to the report, repeat the formatting (steps 4 and 5 in “Creating a Slicer from the Same Table”).
  2. Recreate the matrix as described in the section “Creating the Matrix.”

Continue learning how to get the slicer to work filtering the matrix if you choose this method for the slicer.

Discriminating Measures and Calculated Columns

Before moving on, it’s essential to consider why you should build measures rather than calculated columns. DAX expressions are accepted in both measures and calculated columns. They do, though, vary in a few respects. Measures are used on aggregations row by row while the calculated column expression is analysed in the row context.

Another crucial distinction, and generally the most simple one to remember when making a decision, is when the calculation is performed. As the table is processed, the calculated column expressions are evaluated, and the result is preserved in the Power BI file. They can’t rely on any contact with the visuals because they’ve already been calculated.

This simplifies the decision: you’ll need steps that respond to the slicer range as the consumer makes it. Another explanation is that these measures would be calculated on each line of the matrix, essentially an aggregate of five records.

Creating the Measures for Filtering

To sort the rows depending on the chosen numbers, you’ll need to build a single measure to see if each row on the slicer has the specified numbers. It’s a boolean variable that can return true or false, but here’s the trick: Since boolean measurements for filtering don’t fit well in Power BI, you’ll need to build it as a numeric measure that returns 1 or 0.
Another problem with this formula is that it shows all rows while the slicer has no selection. In this case, the test should return 1 for all rows, implying that it is displayed.

This calculation will be determined for each row of the matrix, which is made up of five numbers. The slicer, on the other hand, would have a series of numbers that you don’t know how many there are.The result should be 1 (show the line) if any of the slicer’s numbers are contained in the drawing numbers in the row, otherwise 0.

You will use a DAX expression to build variables within the expression, which you can use to solve this problem. Here’s where the expression starts:

LineFilter =

VAR tab =   VALUES (Selector[Number] )

VAR tab2 =  VALUES ( Lotto[Number] )

VAR common =  INTERSECT ( tab, tab2 )

VAR rowsCommon =  COUNTROWS ( common )

VAR rowsSelected =  COUNTROWS ( tab )

It’s vital to consider the context in which this expression was processed. Since the expression will be analysed on each line of the matrix, the Values function over the Selector table will return either the numbers chosen on the slicer or all the numbers, while the Values function over the Lotto table will return only the numbers over the current drawing line.

If the rowsCommon variable is equal to the rowsSelected variable in the final part of the expression, all numbers selected on the slicer are on this drawing, and the result is 1.Otherwise, it will be 0.However, you should consider whether the slicer is filtered at all. You can use the ISFILTERED DAX function for this.

The full DAX expression is:

LineFilter =

VAR tab =   VALUES ( Selector[Number] )

VAR tab2 =  VALUES ( Lotto[Number] )

VAR common =  INTERSECT ( tab, tab2 )

VAR rowsCommon =  COUNTROWS ( common )

VAR rowsSelected =  COUNTROWS ( tab )

RETURN

    IF (

        OR ( rowsCommon = rowsSelected, 

          NOT ( ISFILTERED ( Selector[Number] ) ) );

        1,

        0

    )

The steps to use this expression are the following:

a. In the “Fields” pane, Click the ‘…’ (More Options) button close to the “Lotto” table.

b. Click the “New Measure” menu option in the context menu that will appear.

New Measure

a. Paste the entire expression, including the measure name, in the formula bar.

measure name

a. Drag the newly generated measure to the matrix configuration’s filter area.

b. Change the comparison expression Show items when the value to is

c. Fill the value expression with 1.

matrix configuration's

d. Click Apply Filter

The filter will be operational after you’ve finished these steps. When you use the slicer to choose multiple numbers, you’ll just see the draws that include all of the numbers you’ve chosen.

multiple numbers

Conditional Formatting

The conditional format is the “cherry on top” of this solution. You can not only filter the drawings, but you can also use a different color to highlight the numbers chosen on the slicer inside each line.

The slicer’s numbers can show in red or whatever color you choose. For conditional formatting, this is too complex. As a result, you’ll need a new metric that tells you whether or not each number in the drawing is chosen.

This calculation will be processed for each number rather than collections of numbers, so it will only be used for conditional filtering. However, since it’s a metric, you’ll need to use an aggregation function on the “Number” field, which can be as simple as SUM.

The final measure will look like this:

NumFilter =

VAR tab = VALUES (Selector[Number] )

RETURN

IF ( SUM ( Lotto[Number] ) IN tab, 1, 0 )

The steps to complete the conditional formatting are:

a. In the “Fields” pane, click the ‘…’ (More Options) button close to the Lotto table.

b. Click the “New Measure” menu option in the context menu that will appear.

c. Paste the entire expression, including the measure name, in the formula bar.

New Measure

b. In the “Visualizations” pane, with the matrix selected, click the “Format” button.

IMG27

Visualizations

a. In the “Visualizations” pane, open “Conditional formatting”.

b. Under the “Conditional Formatting” element, enable “Font color” option.

Conditional Formatting

a. Click on the “Advanced Controls” link that will appear below the “Font color” option.

b. In the “Font color” window, on the “Format by” dropdown box, select “Rules”.

Font color

On the “Based on field” dropdown box, select the measure, “NumFilter”.

Based on field

a. On the “If value” dropdown box select the “is” option.

If value

1. Type 1 in the textbox besides the previous dropdown.

2. Select “Red” in the color picker, if not selected already.

3. Click “Ok”.

Once you’ve finished the steps, the chosen numbers should light up in red or the colour you choose.

colour you choose

Power BI Training

88

Weekday / Weekend Batches

Conclusion: 

Each line of a matrix may be filtered according to a slicer using some sophisticated DAX expressions. Furthermore, the numbers chosen may be highlighted. By using the Matrix visual, you can apply the expressions presented here to  your challenges.

Related article:

Power BI for Mac

Power BI Visualization



Source link