Transcription
Hello friends, hope you had a really good start of 2025. I, Amit Chandak, a Microsoft Data Platform MVP and a Power BI community super user, I also chief Altic officer at Caner, welcome you to this video, Learn Power BI. Yes, it is a full video of 20 hours. In 2023, I released a similar video of 11 hours and 30 minutes. I'm taking a next step to bring you even bigger and better content. We are going to cover visualization, DAX, and Power Query in details. I'm hopeful this video will help you to enhance your journey of Power BI in a great way. Start this journey with me, and I will take you through a content which consists of more than 140 plus videos which has been recorded and edited throughout 2024. You will find some of the UIs have changed over a period of time, but I've taken care that I have incorporated the new UI at the right place. So let's begin this journey, Learn Power BI.
The data analytics industry is continuing to grow, and it creates a lot of opportunities for business intelligence, data analytics, and visualization tools. Power BI is leading that weave today. With the emergence of Microsoft Fabric, it has taken the next step in that journey. So learning Power BI as a skill can be really useful, and I have done an attempt to make sure that I cover all those aspects in this particular video.
I would also like to take this opportunity to thank each and everyone of you who have watched the previous video, where over the last two years there were more than 200,000 views and 4,000 likes. You have really appreciated that video. You have asked many questions on that video, and based on that, I have created many other videos. The channel now has more than 850 videos, and you can take full advantage of those videos. More than 500 videos are only on Power BI, and there are more than 80 plus videos on Microsoft Fabric, including English and Hindi. So my advice would be to watch all these other videos other than this course to take the full advantage of Power BI. There are detailed videos on each and every function of DAX and Power Query on my channel, and you should also watch other than watching this full course. I wish you a very successful Power BI journey with this video and hoping that this video will make your Power BI journey really easy. In case you have some questions, you can ask them in comments, but with that, let's begin our journey in 2025 to learn Power BI and take a next step in your data analytics career.
So friends, the question arises: why Power BI? Power BI is a leading business intelligence analytics tool, and for the last many years, every business intelligence analytics industry report puts Power BI as the top leading tool in terms of feature and capabilities. With the launch of Microsoft Fabric, an integrated environment where Power BI is also part of it, which has capabilities of having lake houses, warehouses, real-time analytics all together on an integrated platform, as a Power BI developer, you have a leap to take. My recommendation is, with the help of this video, you learn Power BI and then take the advantage of various other videos on my channel to learn Microsoft Fabric. 2024 is expected to be the era of Microsoft Fabric, and you have a pivotal role to play as a Power BI developer and enhancing your skill to the next level to the Microsoft Fabric, becoming a Microsoft Fabric developer. So let's start together this exciting journey of learning Power BI, taking the analytics experience to the next level for the end-user and then take it to the next level using Microsoft Fabric.
So let's understand what is Power BI. Power BI is a business intelligence and analytics service that delivers insight from analyzing the data. Power BI is a collection of software services, apps, and connectors that work together to turn your unrelated sources of data into coherent, visually immersive, and interactive insights. It can share those insights through data visualization which can make up reports and dashboards to enable fast, informed decisions. Power BI scales across an organization and it has built-in governance security allowing businesses to focus on using data more than managing it. In today's data-driven world, Power BI stands out as a pivotal tool in the data visualization and business intelligence. It is not just presenting the data; it's about unlocking the insights for decision-making. So let's begin this interesting journey in the world of Power BI.
So whether you're a beginner or eager to dive into the data visualization or a professional looking to update your skills, this video is a gateway to mastering Power BI together. Let's transform the way we understand the data. So the first term is data itself. So data is a set of values of qualitative or quantitative variables; means something which we want to measure against something which we want to measure, and it's not only about data, it's about quality data. See, in business intelligence and data analytics, we use a term: garbage in, garbage out. What does that mean? If you if you don't have quality data, you'll not be able to get quality analysis, and that's really important here, and that might require transformation, and Power BI is capable of doing the transformation.
Then we have a term: data analytics. Data analytics is the process of examining and analyzing the data sets in order to draw insights, conclusions, and make data-driven decision-making. So we are talking about data-driven decision-making. It involves using statistical and analytical techniques to extract and interpret relevant information from data and can be applied in a wide range of fields and industries. So basically, we are driving out the information from the data; we are taking decisions which will drive our businesses. We have another term which is business intelligence, and business intelligence refers to decision-making. Now, according to o.com, the term business intelligence, BI, refers to the technology, application, and practice for collection, integration, analysis, and presentation of business information. The purpose of business intelligence is to support better decision-making. Now here we are talking about collection of data, integration of data, analysis of data, and presentation of data. Power BI can do all four; means it can collect data from different sources, it can integrate them, it can analyze and present. Also, it could happen that most of the time this collection and integration is happening outside, maybe in a data warehouse, and analysis and presentation is going to happen in Power BI. Now data could be structured, semi-structured, or unstructured. Most of the time we are going to deal with the structured data, and this structured data can come from RDBMS, and sometimes it may be also available in Excel files or CSVs where targets and budgets are commonly kept. Now ideally, we should move them into the data warehouse or a common storage so that they can be managed properly, but in any project you will not have 100% data coming from RDBMS. You may have some data coming outside. Now semi-structured data and unstructured data would be dealt with a little bit outside the Power BI or maybe converted into some useful information or data and then maybe given in Power BI for analysis.
Now you will come across the term tables and fact. Now table is basically a collection of related data entries, and it consists of numerous columns and rows. So there are rows and columns, and it contains data. Now table could be a fact table or table could be a dimension table. Fact table is the table which contains the majors or the facts. Facts mean truth about your organization: my sales, my purchase, my inventory, number of employees, their salary; all these are the facts of your organization. They are the truth about your organization that are used to analyze data as well as dimension keys against which they need to be analyzed. So it will also contain the dimension keys against which you need to analyze this data. You will also hear this term: measure, matrices, KPI, and then you will also hear the term: parameter, filter, dimension. So what is measure? So something which you want to measure, measure for your success of your organization, and then you will measure it against something: against time, against geography, against customer, against vendor, against items, articles. So you say I have done good sales; sales is a measure or matrices. What is what do you mean by good? Have you done good against your competitor? Have you done good against last year? Have you done good because your margin has increased? All these questions are there, and such questions we will be trying to answer using business intelligence and data analytics. So these are the terms you should be hearing time and again. Then there are two kinds of matrices: lead matrices and lag matrices. Lead matrix is something which can indicate what is going to happen; lag is something which is actually analyzing what has already happened. Sales is basically something already has happened, but is sales going to decrease? How you are going to know? So it's basically the size of your funnel: how many opportunities or leads you have. If your leads are decreasing, your opportunities are decreasing at 1 F day, your sales will decrease. So there are lead indicators, and that is how the prediction happens. So somebody's saying okay, downtime is coming, or how this is coming because they look at the lead in mates, and once the lead in mate is going down, we know that the lag matrix will follow it soon. These kinds of matrices you should also remember in your analysis, what you plan to analyze.
Now you will hear about relational schema, star schema, and snowflake schema, and star schema is a very common term which you will hear while you are doing your analysis. Now without going into a lot of details of this one, let me explain you one quick example. In typical in a relational schema, what happens? We try to store information in such a manner that it doesn't repeat at all. So let's say if I store state in a city table, what would happen? The state name will repeat for many cities. So instead of storing the state name, what I'll do, I'll create a state ID and state name in a separate table, and I'll only store the state ID in the city table. So if the state name changes or updated, I'm only updating one record. So in such a manner, we create a set of tables using a process called normalization, and relational schema or the OLTP system, online transaction processing system, which are our base core ERPs or CRMs, they typically follow relational schema back because of which they are able to handle thousands of transactions or millions of transactions in a day. So this is typically how a relational schema looks like. You might have a sales table; sales might have a detail; sales might join to city and state; it might join with time, and time may be further classified as date, month, quarter, year; there could be separate tables or one table; it could be joining with customer; customer can join further with customer group; CS detail can join with item; item can join with brand, category, subcategory, and all so many tables could be there. What what happens is then this is relational schema; we have a dimensional schema; there are two dimensional schemas which are pretty common: one is Snowflake and second one is star schema. Now what happens in case of snowflake schema? You can still have subdimensions like I combined sales and sale detail here; I combined also customer and customer group, but I still have item and brand; means item table is there and it's also connected to brand. You can also have city and state; means still separate out table; time is one combined; it maybe previously also combined; I also combined, but when you come to star schema, what happens is that you do not have any join between dimensions also; so no fact join with other fact, no dimension join with other dimension, and the distance of information is one. So I want to know brand-wise sales, item-wise sales; the distance is one, one join. I want to know state-wise sale; one join. I will get state. I want to know customer group-wise; one join with customer table; I'll get that information. So I can have many joins, but all these joins are just one step apart; that's what the star schema, and in that one fact will not join with fact, dimension will not join with dimension. So these are basic few concepts which should be aware, and you will hear all these terms time and again. So let's begin this journey of learning Power BI.
To start this journey, let's first understand Microsoft Power BI ecosystem. This ecosystem does not include Microsoft Fabric ecosystem; I have knowingly excluded that which we can discuss in a separate video of Microsoft Fabric. You can watch the introduction videos in Hindi and English on my channel explaining the various components that Microsoft Fabric provides you. So the journey of any business intelligence analytics tools starts with the sources. So what kind of sources we can have for Power BI? The usual sources are external sources like Excel, databases, etc. Then we will discuss later on about these remaining two sources. You import that into the Power BI Desktop. For databases, we do have an option for direct query. What is import? In case of import, the data would be residing in the Power BI, and we will be creating the model into the Power BI, and we will be creating measures and would be analyzing the data also. So Power BI own meta as well as data. In case of direct query, we create the connection; we do not import the data, but we create the metadata; we create the model; we create the definitions; we create the relationship; we create measures; we create visualization; finally analyze. So Power BI will have model, Power BI will have visualization, but will not have data; that is direct query mode. Now once you create your Power BI report on the desktop with the help of transformation using Power Query and measures and calculation using DAX and finally creating visualization using Power BI, you can publish this file on Power BI service. Power BI service is the ecosystem where you are going to share this report and do the collaboration with other users. Power BI Desktop is a development tool; it does not have security. You can create roles to apply the security on Power BI service, but unlike Excel where it is password protected, that's not Power BI Desktop. Power BI Desktop, all the information is available; you can restrict what you wanted to load, but the entire information is available. So once you are done with your development on Power BI Desktop, you publish it to the Power BI service. Now if you are using on-premise sources, you need on-premise gateway; that includes on-premise databases like SQL Server or Excel sheets; you need on-premise gateway. If your sources are cloud, you don't need on-premise gateway; they can directly be refreshed on service. Remember in Power BI Desktop you have a refresh button to refresh the data. On the service, we can schedule the data set refresh automatically to happen 8 times for pro, 48 times for premium users. When when it goes to Power BI service, the report which you publish, the PBIX which we have on the desktop, it gets divided into two parts: one is data set or what we call a semantic model, and another one is report. The data set or what we call a semantic model; it can also act as a source again, and you can create report, paginated report, and dashboard on top of it. You can take it back to the Power BI Desktop and again create a report which you can publish; you can reuse it on the report developer; paginated reports can be created using this data set and that can be published again on Power BI service known as paginated report. So it means once you create the data set, you will be able to use that again, and the connection this time we are going to create when we use the data set is known as live connection. Reports will have a live connection in this case. You can finally create a Power BI app and distribute the content, and this is really helpful when you want to distribute it to the large number of users. You can combine multiple reports along with the dashboards and share it with users. You can create create multiple audiences and share different sets of reports with them.
Now let's talk a little bit about two components of the Power BI Desktop. So one of the components of the Power BI Desktop was Power Query. Power Query is used for data preparation, data cleaning, and data transformation. DAX is used for creating complex measure calculations which help you to finally create the analysis. So what happens is in Power Query, whatever you transformation you create remains with that file, but what happens if we have to do the same kind of transformation again and again? How do we keep its record across various users or various files? So to address that, Power BI has come up with the online version of Power Query, and that is known as data flow. In Power BI world, we use data flow Gen 1 or data flow. In Microsoft Fabric world, we use the next version of data flow, which is known as data flow Gen 2. Data flow Gen 2 is the online version of the Power Query, and you can use it for data preparation, data cleaning, and data transformation. Now data flow Gen 2 stores the data, but it cannot create a data set, so you have to bring it back to the Power BI Desktop and then create your data set. After you create the data set without creating a visualization, you can publish that data set; you can use that data set back to create the visualization, and this is one of the patterns we use now in the data flow. We may not have all the heavy tables, dimensions, or the small tables which which have a lot of transformation can be part of data flow. So have the dimension table or small table having a lot of transformation in the data flow, take it to the Power BI Desktop, merge it with other fact tables, create relationship, create measures, create all the complex calculations which you require without creating a visualization, publish it, and create a Power BI data set or what we call a semantic model. So the term which we are using now for a few months is semantic model; create your semantic model and use that in the live connection on Power BI Desktop or in Power BI service itself; you can create the report and visualization; same can be used in Power BI now. Now you would have understood why I kept PBI data flow here. Then what is this one lake and what is this almost very similar icon? What happens is basically in Microsoft Fabric, we have a direct lake connector. In Microsoft Fabric, most of the things reside on lake where whether it is the structured data or unstructured data, we save it using lake houses or warehouses, and lake houses and warehouses create a data set or what we call a semantic model. The data set or what we call a semantic model directly gives you data from lake houses and warehouses and it doesn't need a direct query; it is a best possible merge of import and direct query. So there is a new connection type which is direct lake connection type. So when you connect to the one L Lake, you get a new kind of connection which is a direct lake connection; semantic model created on the lake houses or warehouses or the custom semantic models created on lake houses or warehouse. So in this manner, you can use the direct lake connection and you can now create the reports using the direct lake connection and then publish them again to the Power BI. There is one different version of Power BI which is known as Power BI Report Server which can be installed on-premise. There is a special IAL version of Power BI Desktop available for that; that is known as Power BI Desktop optimized for report. It is usually 3 to 6 months behind from the current Power BI, and it also does not include preview features. There's a whole list of comparison what you don't get available on the Microsoft side. Power BI Desktop or Power BI, we get 11 releases per year; other than January, every month we will have one release. So your Power BI Desktop keeps on updating every month, but that's not true with reports; or we have only three releases in a year, and because Power BI does 11 releases, it's really important that you keep an eye on blog.powerbi.com and always keep on monitoring the latest update because features keep on changing fast. One of the reasons for creating this video again is that we have got quite a few new features, and there are so many changes in the UI that it could not have been done without creating a new new video, and that is why we again created this entire video for you to learn the Power BI on the latest version which has been released in December 2023.
So now let us understand the process of creating a Power BI login. One of the best methods is that the admin of the tenant should use admin.microsoft.com. If you have your own registered domain, for that domain you should go ahead and register yourself to admin.microsoft.com, and once an organization is able to register and admin on admin.microsoft.com, you will be able to create users and able to assign the licenses to them. So let me go ahead and showcase you how you are going to do that on admin.microsoft.com. So first of all, log in to admin.microsoft.com. I'm assuming you already have the admin.microsoft.com access and you are admin; if not, then this step needs to be executed by your admin. The admin needs to go and register a new user, and under the user management, either you will...
Click on the users, active users, and you should get that option, add users. Or on the homepage, you will also get it, so click here on “add a user.” You will get a popup here. You start giving details of the user. Amit. Amit will display name. Let me give a username here: Amit C. So I’m creating a new user on the Microsoft portal. Usually, you can share this password to another email ID, which could be the email ID of that person, the personal email ID, or the manager’s email ID, or the admin’s email ID. Then go ahead and press the next button.
In the next button, you can assign the licenses. Right now, what I’m going to do is I’m not going to assign the license to this particular user. I have the only thing which I can assign here is the Microsoft Fabric free licenses. I don’t have any Pro licenses to assign to it. Usually, the organizations will have Pro licenses. In my case, in this tenant, I don’t have Pro licenses, so I’ll not be able to assign. So I’ll say “create user without product licenses” and press on next. Then it will ask for additional options, which I’m going to skip. These are the details; anything I want to edit right now, I can edit it and finish adding. Post that, this user needs to log in and change its password. Right now, it is showing us the password which this user is going to get. So right now, it is showing the details along with the password which this user is going to get for the first time. This user needs to log to app.powerbi.com or any other Microsoft application and reset its password. If you have enabled two-factor authentication, that also needs to be enabled. By executing this exercise on app.powerbi.com, the user will be able to claim the Microsoft Fabric free license or the Power BI free license if your organization has not disabled that. I’m going to show you the next step: how the user, in this case, when we have not assigned him the license, we go ahead, reset its password, and going to get the Microsoft Fabric free license which is available for all the users in this particular tenant admin has registered your login, and now the time has come to log to app.powerbi.com.
In the first login, it may ask you to reset the password as well as set up the two-factor authentication if that is the requirement from your tenant side or from your organization’s. So let’s jump onto the app.powerbi.com. Open app.powerbi.com. Once it is open, enter your email ID which has been provided to you by your admin. Once you give that email ID, post that you can click on submit. It will take you to the next page and ask for the password. You have to give the password which the admin has provided to you. Enter the password and click on sign in. After you enter—because the admin has set up your account and you are logging for the first time—you need to reset the password by giving the new password and click on sign in, then press next on the next screen. Now you need to set up the Microsoft Authenticator or any other authenticator which you want. Click on that and next. Then you need to scan the code, and you will be able to set up your authenticator. Provide the six-digit code from your authenticator here, and then again press next. Your authenticator is successful. Once the authentication is successful, you should be able to sign in to app.powerbi.com. Once you log in, you should be able to see a free account for you. So authentication is successful. Let’s go onto the right top, the user details. Click on the user icon; you should be able to see your email ID and the type of license what you have here. Here you can see I have got a free account, and Microsoft Fabric trial is also available for me. In this manner, you will be able to set up your account.
So now let’s understand Power BI licenses. Typically, Power BI licenses can be divided into three categories: free license, Pro license, and premium license. Premium has two parts: PPU and premium capacity. With the emergence of Microsoft Fabric, you have more options to know the information about Power BI licenses. What you can do is search for “Power BI licenses” on the web, and you will get the product pricing for Microsoft Power BI. Now when you go to the pricing, depending on the country which you are in, you can see the pricing, and what I can do is, instead of “in,” I can make it “US.” So now I got the US pricing. So depending on the country, you can change it and get the pricing. So first of all, Microsoft Power BI in a free Fabric account, you have a Microsoft Fabric free account; there you can get the free Microsoft Power BI. Microsoft Power BI Desktop is already free; you have—you can create a Power BI free account, Fabric, and you can get it. Then we have the Power BI Pro license, which is basically the user-based license, which is $10 per user per month, and you can publish and share reports. Power BI Pro is included in Microsoft 365 E5 also, and you can buy it using the credit card also. Then we have Power BI Premium per user. Premium per user includes the features that are available in Power BI Pro; additional features in the Power BI Premium. There are few premium capacity features which are available here, and you can buy it; it is $20 per user per month, so double the cost.
Now when you further go down, it talks about the capacity. Basically, because of the merge with Microsoft Fabric, this is Power BI Premium capacity can also be used for Fabric; so that is why Microsoft Fabric Power BI Premium capacity SKU. The SKUs which start with P1, so those SKUs you have: do 4,500, 4,995, which is P1 capacity. Include all the features available in Power BI; gain access to the rest of the Microsoft Fabric workloads as a unified product; use autoscale to respond to occasional unplanned outage and spike in the capacity by automatically adding one V-core at a time per hour. So if you want to autoscale, then there are separate charges. Now when you go to Microsoft Fabric capacity, which is F64, equivalent of P1, you get licensed to your organization access for Microsoft Fabric in a unified product experience that uses the same compute capacity and storage. Smaller entry-level start from F2. So the capacity starts from F2. In Power BI, the premium capacity only starts with one, which is equivalent of F64, but here it starts from F2. Microsoft Azure consumption commitment eligible and gain access to full Microsoft Fabric workload through unified product experience capacity that is also there. Then we have per month F64 SKU, P1 equivalent Microsoft capacity pay-as-you-go. This is pay-as-you-go. This is very similar to the F64, but you can shut down this capacity pay-as-you-go, and this is basically you kind of hourly capacity which you—again these kind of capacities start with F2, so F2, F4, F8, F32, F64; these kinds of capacities are available. Then when you further go down, it talks about E5. Power BI Desktop which is free; you—it’s available. Microsoft Power BI for mobile, Power BI embedded. When you further go down, it compares the features of Power BI with Power BI free account, Pro account, premium account, and premium per capacity. If you go down here, look at this comparison. Create reports with desktop; available everywhere. Publish reports and share collaboration; see, you can’t do the collaboration without having any license, so you—so you at least need a Pro license for collaboration. Then advanced AI and data flow, Data M, XMLA endpoints are only available in the premium feature. All users can consume BI without paid per-user license is only available with premium capacity, P1 or F64 onwards. So viewers, viewers don’t need a license from those capacities onward. Access to all Microsoft Fabric workload including data factory, data engineering, data warehousing, data science, real-time analytics, and data activator is only available with P1 capacity or F64 capacity. Premium capacity memory size limit for you will—very—get very small memory size limit for free account; 1 GB for Pro, 100 GB for PPU, and 400 GB for P1 premium capacity. Refresh rates for Power BI data sets: 8 per day for Pro, 48 per day for PPU, and 48 per day for premium capacity. Maximum storage Power BI native storage; when you are using Power BI, then this is applicable: 10 GB PPU, 100 TB and premium capacity P1, 100 TB. Data security encryption available everywhere. One L storage, one L B CDR storage, one lake cache, one networking only available with premium premium capacity or Microsoft Fabric capacities. There are additional notes and comments. I will also provide the link of this one into the description. So those who have looked at the older pricing, now you will see few differences in the pricing, and these differences have come because of the availability of Microsoft Fabric and Fabric capacities. Previously, without having a premium capacity, you cannot buy a capacity; that’s not true in case of Microsoft Fabric world. You can buy an F2 capacity and start with that, and you can buy Pro licenses and can start using all the features of Microsoft Fabric and Power BI. So now you have lot more options to buy capacity because Microsoft Fabric allows you to—to have capacity as low as F2, and the pricing starts very low. You can check out the prices on the Microsoft Fabric page for that.
Let’s understand various options to install Power BI. There are two very common options to install Power BI: download and install. So you can go to the Power BI site, or you can search on the internet, download and install it. What is the advantage of this? You can control the installation version; you can decide when to upgrade; it is supported on most of the versions of Windows, and you don’t need Microsoft Store for that. So if the Microsoft Store is not there, you don’t need it. But what is the disadvantage? See, Power BI updates almost once in a month. If you don’t update, there is a fair chance that you will be lagging behind, and sometime I’ve seen users are as behind as one year, and it is—is really difficult from that stage to upgrade it. You will miss out on the features and new launches because you continue to work on an older version, and you might have a better solution available in the newer version which you may miss out on. The second way to install Power BI is use Microsoft Store. You don’t require admin privilege for the installer to install this one. So if the Microsoft Store is enabled, you can install it. As the Power BI releases new versions, it will get automatically updated, so you will get it. What is the disadvantage of this frequent update? Sometime what happens is when the new release comes in, it has its own changes which have come in, and some certain things may break because of that; all of a sudden you will start seeing those—those changes. Now this is a better method because everybody in the organization would be on the same version. If you download and install, not everybody would be in the same version, but yes, there are methods where the—it can install or push the Power BI version on all the desktops; that can also be controlled using it. So that is one more method where it can control what version you have, and then they can keep the entire organization on the latest version.
To install Power BI, I have opened my browser, and in that I have used the search engine and searched for “download Power BI.” After the search, I got few results, and the first result is the most appropriate result for me, which is giving me a link for HTTP powerbi.microsoft.com/us/downloads. Depending on the country and language, you can get different links. Once you click on this link, you will get this page, which is the Power BI download page. Scroll down on that and use “Advanced download options.” Once you click on the advanced download option, you will come to the download page which will allow you to select the language and the download option. If you go further down, it will let you know which version and when that was released. So right now, when I’m recording, the latest version is published in December 2023, and the version is 2.124.2124.052.0. If you further scroll down, it will tell you about the uses of Power BI Desktop and most importantly is the system requirement: what all are supporting operating system and installation instruction. You can also search for “how to install Power BI,” and you will get a link of this document. I will share the link of this document in the description. And if you go down, it shows you the various options to install. The link is also available on app.powerbi.com, and we can—can install by download, and what are the different requirements. So I can go back to the download page and download Power BI, but this is not the mechanism I’m going to install, as I’ve already told you, there’s an advantage of installing Power BI using Microsoft Store, so I’m going to use that. But just for your reference, I’ll click on the download button—button and use 64-bit because I’m working on a 64-bit and click on download. Once it is downloaded, you can double-click on it and follow the installation instruction. Power BI Desktop download of EXE file has been completed, and if I click on it, it will open the installing a window. I can select a language and move forward. It will ask for the permission, and it will start installing the Power BI Desktop, and it will give you the wizard. So you can press on the next, accept the agreement, next, you can choose a location, next, and click on the install button. I’m not going to click on the install button because I’m going to install the version which is provided by Microsoft Store, so you can install if you want the downloaded version. The advantage of this is that you can control which version you want it to have on your desktop, but in any case, make sure that you are not 3 to 6 months behind in the release. I’m canceling it, and now let me search for “Store” and open Microsoft Store. In Microsoft Store, I will search for “Power BI.” Once I search “Power BI,” I get few options: Power BI, Power BI Desktop, Power—Power BI Report Builder, Power BI is Power BI app, which is the same as your iPhone app as well as your Android app; it is a Windows app. What we need here is for our learning is Power BI Desktop, and I’ll click on “get.” It will start downloading. I double-clicked on it; it—I can see the install button. I can click on the install button, and it will start downloading it and we install Power BI Desktop on my Windows machine. It may take a little bit of time. The advantage of this method is every month whenever there is a new release, Power BI Desktop will get automatically updated. Once the installation is finished, we will go ahead and start Power BI Desktop. Continuing installing Power BI has—has installed, and time to open. I can click “open” in the Microsoft Store, or I can search “Power BI” and open Power BI Desktop. Let me click on “open.” Power BI Desktop is opening up, and let—let me give you a quick overview of Power BI Desktop.
Power BI Desktop has opened, and it is showing me the welcome screen. Some of you will not get the welcome screen because you might have enabled Power BI home from options and setting option preview feature that we will discuss in some time. When you open the Power BI Desktop for the first time, you’ll get this welcome screen, the “get data” option on the left-hand side, and recent sources. You might not have recent sources for the first time, but as you start creating content, you will be able to see recent sources and also be able to see some of your reports under this left-hand side section, “open other reports.” So what we will do now is we will cross this screen and enter into the Power BI Desktop. You can start the journey of the Power BI Desktop by signing in into the appropriate account, or you can start your development, and when you want to publish, you have to sign in. Now before I tell you how to sign in, I would like to show you what all we have on the Power BI Desktop, and some of this what we are seeing is because of the settings I have done on December 2023, and one of the settings which I have done is available from December 2023. If you go down into the release notes of December 2023, you will find that we have been offered an option when we opened it for the first time: “choose the pane arrangement that works for you.” You can always customize the setup later by going to settings: “keep current setup,” “use more classic pane setup.” I like this classic pane setup where I have the build visual, I have the visualization type, and I have used “update setup.” Now the old setup which was there was because of “on object interaction,” which is still enabled in my case, and I will let you know about that setting. Those who want to follow this video and want to learn, I would recommend them to use this option, “update setup,” in case they are getting it. But I will let you know how you are going to get some more options in your options and setting where you will be enabled these things even if you have not chosen for them for the first time. So let me jump back onto the Power BI Desktop and give you an overview of Power BI Desktop. On the Power BI Desktop, on the top, we have this ribbon which contains the menu item for file, home, which is currently open, insert, modeling, view, optimize, help, and external tools. We will use them as we go forward. Inside the Home tab, you can see “get data,” using which you will be able to get the data from various sources, and we will start our journey by getting an Excel source, at Excel workbook. We have a quick connector, Data Hub; again, we have quick connector, Power BI semantic models, Dataverse, lakehouse, warehouse, and—and KQL databases, SQL Server. We can enter the data; we can use Dataverse as a connection, and we can use some of the recent connections. “Transform data” is there to go to Power Query. Power Query is used for transformation of data, and then you can alter your data source setting or you can modify some of the data source setting using “data source setting” option. Those of you who have enabled “on object interaction” will get this visualization option, but if you don’t see this option, it means the “on object interaction” is not enabled. When I’ll go to the preview feature, I’ll let you know more about that. In the Insert tab, again you have the visualization insert option along with the more option. Then you have key influencer, decomposition tree, narrative page, report, Power App, Power Automate, text boxes, etc. All these are the visualizations which you can insert into the Power BI Desktop or the components which you can insert to make or beautify your Power BI Desktop report, and once you publish it, it will become the Power BI service report. Under the Modeling tab, you will get quite a few options. Right now, some of these options are disabled because of the reason we have not added any data. Once you add data, depending on what is available, one or more options will be enabled. So “manage relationship,” once you want to create the relationship; “new measure,” once you have the data; “quick measure” to quick create measures; “new column” to create new calculated column; “new table” is available because we can start our modeling by creating a DAX table; “new parameter,” we will explore this option later to create dynamicity in the content; and then we have language and linguistic schema options. In the View options, you have the theme, which is one of the first things we are going to do. Then we have the page view and the mobile layout. Then we have grid lines, snap to grid, lock objects, etc., for various options. On the top, you have various pane options which you can use to enable and disable various panes. So like for “filter pane,” I can enable or disable it using the filter pane. So as you can see now, there is no filter pane. I have enabled it again. Similarly, you can see the data pane here, the build visual pane here, format pane here, and then you can customize by clicking here, or you can add by checking it here. So both of them are going to do the same job. Let me enable the Bookmark tab. I got a Bookmark tab, and as you would have noticed the moment I pressed this and I got this; this is also enabled. So let me disable, let’s say, format pane. So there is no format pane available. Let me disable the data pane. Now there is no data pane. We got the data pane; we got a format pane here. Now we got a selection pane also, and as you can see the selection is enabled here also, and to get the selection pane, you can click. Some of the panes will open in a mode where they are not expanded. So if they are not expanded, you can actually click on the pane here and expand it. Similarly, we have “performance analyzer” pane again on the top and on the left, and once it is open and if it is not visible, you can click on the left-hand side to check it.
Out performance analyzer helps us to analyze the performance of the visual, and we can see the timing and we can go ahead and analyze that in a better manner. Syn slices is another pane which we can open to sync these slices; the feature we will explore later. I'm collapsing all these and taking my focus to one of the panes on the left-hand side, which contains the various views. The report view, which currently we are on, then we have the table view, model view, and recently we also got DAX query view.
Now, table view right now would be empty. Once we have the table, which can be seen on the right-hand side on the data view, we will be able to see some table and data. Table view or the data display is dependent on which kind of mode. Usually, all the import mode tables are available. In case of pure play direct query and live mode, we might not even get the table view. Then we have the model view, where we will be able to see our model, and the DAX query view, where we will be able to run the DAX query. Inside the DAX query view and inside the relationship view, both views contain something known as model, and this will help us in creating calculation groups. Calculation groups were previously created using external tools like Tabular Editor, but now we can create calculation groups inside the Power BI Desktop, and we will explore that also.
Before we go into the options and setting, just let's quickly look at which version of Power BI we are on. I know we have installed a particular version, but in case you wanted to check because there are monthly updates ongoing and you want to know which version you are on, click on File, go to About, and you will be able to see which version of Power BI Desktop you are on. What we are going to do now is we are going to enable the preview features, or I'm going to tell you what preview features I have enabled. So when we take this journey, you are on the same page where I am now. Now, as Power BI releases almost one release per month, some of these features will change over a period of time. From the public preview, they will go to GA, and there would be no options for that in public preview. There might be options in some other setting for enabling and disabling, and the same way, there will be some new features which are coming in which will appear in the preview features.
So first of all, let's go ahead and explore what all we have inside the options and setting. An option to go there: you need to click on File, Options and setting, Options, and you will get a popup. In this popup, you have options like data load, and inside the data load, you have type detection like detect type and header of unstructured source. According to each file setting, means the file setting is going to decide whether we need to do it or not. Background data: allow the data previews to download in the background. According to each file setting, means it is depending on the file setting. Parallel data loading: when you load the data into Power BI via import mode or direct query mode, each table is backed by Power Query. These queries are evaluated simultaneously instead of one by one. So how much parallelism you want, you have enabled that. Typically, we keep this enabled. Auto date time intelligence, but I personally don't prefer it, but at least I would like to show you what that means, so I'm keeping it right now. Clear cache: a data management cache. If you want to clear, you can clear from here, or you can change the size. If you have a pretty big file, I will recommend you to keep it from 8 to 10 GB, like 8, 9, 10 GB. Q&A cache for the Q&A and folder artifact cache. If you want to clear that, then you have options for Power Query editor: display the Power Query setting pane, and display form up bar is default enabled. Data import: enable web table interface is enabled. Data preview: I have enabled show white spaces and new line correctors, and if you don't enable it, you will not see it. Display preview content using monospaced font is disabled. Parameters: always allow parameterization in data source and transformation dialogue. As of now, it is disabled, but we can enable this feature, which will allow the parameterization and formula. Enable M intelligence in the formula bar, advanced editor, and custom dialogue, and there is the information given here. Changing this setting will take place when you next time open the Power Query editor, so it means some of these settings will not apply as soon as you press OK. You have to open the Power BI again; you could close it and open it again. Direct query: SAP HANA as relation sources. Now we are not planning to work on SAP HANA, so we'll leave it as is. Scripting: right now I'm not updating any R script option, also not updating any Python script option. Whatever options you are seeing is because I already have installed Python on my system. Security option: this is another important option. Now, in this option, there are a few important things which you should do here. Is one of the things is if you want to enable the ArcGIS and field map visual, make sure they are enabled. Similarly, authentication browser, you should always choose use my default browser unless it stopped working. Sign-in experience: use updated sign-in experience, you can use that. Approved ADFS authentication service: you have not approved any authentication service, so there is no option coming in. Then for privacy, I'm keeping combined data according to each file privacy setting. In the regional setting, I'm keeping my default Windows setting and language; it means it's going to follow my Windows display language setting, and I'm going to keep it like that. In case you want, you can use the model language updates. I'm not going to change anything here. Uses data: you can disable this feature if you don't want to send any data to Microsoft. Diagnosis: right now I have not enabled tracing or crash T collection, but at a few places the diagnosis is on. Is basically query diagnosis enabled in report and query editor. Diagnosis level: aggregate and detail; additional details are also enabled. Review feature and one of the most important features which we are talking about, shape map visual is enabled here. As you can see, Q&A is enabled. Connect external semantic model shared with me is enabled. Modern tooltip is enabled. Park line is enabled. Metric is visual is enabled. Quick measure suggestion is enabled. Field parameter is enabled. Enhance low-level security editor is enabled. On object interaction is enabled. Power BI Home Desktop is not enabled, which I'm going to enable now. Similarly, also I'm enabling set sensitivity label on PDF is enabled. Dynamic format string major is enabled. Save to OneDrive and SharePoint is enabled. Enhance publish dialogue is not enabled; I'm not enabling that also. How BI project.pbip option of saving is enabled. New card visual is enabled. New button visual is enabled. Model Explorer and calculation group authoring: this is this is the new model view which is available in the relationship as well as the text view. We have enabled that. Text query view you have seen; we have enabled that. Summary with co-pilot visual is enabled. Improve Q&A with co-pilot is also enabled. I can press OK here, but let's have a quick look at save and recovery. As of now, I have set up the store auto recovery information every 10 minutes, but if you have a really big file, please make sure to increase it, otherwise it may slow down because it starts automatically saving the reports. Inside the report settings, these are the important things which we have also seen when we were viewing the December release notes. Display smart grid line aligned: suggest a visual type by default is enabled. In-bit visual menu: always allow show all in the visualization type and then the pane switchers: always show the pane switcher. Always show build menu visual in the panes which are always open in new pane. These are the options which are already selected here. Other than that, I am leaving accessibility and page alignment as is. Now, these are the global features which we have looked at. It, as you can see, they fall under the global feature. There are file-specific features which is there inside the current file, and one of them is data load, and as you can see in the data load, detect column types and header for structure data sources, so it's going to detect import relationship from the data sources. If it is if it is supported on that source, it will be imported. Update and delete relationship while refreshing: it can do that. Auto detect new relationship: now this is the feature you will realize when I am going to load the data into the import mode; it's going to get the relationship, and this is the reason for that; that's going to auto detect the relationship again. I can disable time intelligence at the report level, which I'm not disabling right now. I'm going to show you what's going to happen in that case, and post that will come and disable that if required. Background data: allow data previews to download in the background; we keep it. Parallel loading of table is default; we're taking it from the global level and Q&A; I'm not changing anything here. Regional: regional setting I'm keeping is default. Privacy: default. Auto recovery: disable auto recovery on this file. If you want, you can disable, but I'm keeping it default. Publish data source setting: I'm keeping everything as default. SAP variables: right now I'm not enabling direct query connection to data set. This prevents users from creating direct query connection to the data set on the desktop. If you change the setting, you need to republish your report to save it. Discourage direct query connection: we don't want to discourage it, so we will keep it. Query reductions: keep the default settings and query reduction. Uh, instead of adding apply button to each slicer, it is recommended apply all slicer slicer button to each page, and that we are going to explore. Instantly apply basic changes: add apply button to all basic fields. So this we can use to, you know, what happens is the moment you select anything, the visual gets refreshed. We have apply all slicer button, and or we can use apply on each filter, but what we are going to use is we're going to use the default setting, and if needed, we'll come and explore. And report setting: these are a few of the report settings like use of the modern visual header is enabled. Hide visual header in reading mode is by default disabled; we're keeping it. Export data: allow the end-user to export data, current layout, summarized data from the Power BI service and Power BI Report service. I'm going to keep it because it allows you the currently out means as whatever it is looking like in Power BI service, it should be going in that particular manner, so I'm keeping it. Filtering experience: I'm keeping both of them tagged, and this is also default. Allow users to change the filter type: enable search for the filter pane. Cross-report drill-through: right now we don't need, so I'm not enabling it. Personalized visual is something we can allow on the report level. Modern visual tooltip is enabled, and we'll keep it. Tooltip auto scale: tooltip size affected by the canvas size; this is a preview feature, so let's enable it. Default summarization for aggregated fields: always show default summarization type means if the field is numeric field or aggregated type, we will have a default summarization, and that's where it is asking for query limit simulation. If you want to simulate which kind of capacity you have: shared capacity, premium capacity, SQL Server Analysis Services or Analysis Services, custom limit, no query limits. I'm keeping it auto as of now. This is 1 GB shared capacity. Uh, as of now I'm keeping it same, but in case you want to see if you're on a premium capacity or you want to go to premium capacity how it is going to behave, so that you can enable it. I'm now going to press OK button on the bottom right, and once I press this OK button on the bottom right, I might have to restart my Power BI Desktop to get all these features enabled. So this is a quick overview, and now I'm pressing OK, and it is asking that it requires a restart, so I'll restart my Power BI Desktop and come back again to you.
So let me give you an overview of the data. Whatever data I'm using for this particular video and most of the videos on my channel is available on GitHub. Some of you have complained that you are unable to download the data from GitHub, so so this year I will also provide the data on Dropbox, and I'll share the link in the description. Data primarily is a sales data or the retail data which we are going to use. The GitHub contains a lot many other types of data which we are going to use like for Power Query. I have pyot dat.XLS; there are many other files which are used in different videos available there. So whenever you watch a video and if there's a file required, you will get that here on the GitHub. This time what I've also done is I loaded some icons. I took the help from AI tools to generate some random icons, and then I loaded all those icons on the GitHub so that you can use those icons when you are creating your visualization to make your visualization look much better. So you can take the full advantage of the data available from my side. So let us quickly have a look at what all data is available at the GitHub. All the data which I'm going to use in this video is available on github.com/slamitchandak/PBI-SlavBI. On GitHub, you have various files. One of the most important files which we are going to use in this video is Sales Data Used in Video.do.XLS. Let's download this Sales Data Used in Video and keep with us; we will need it to understand the data. Click on this file, Sales Data Used in Video, and once you click on this, you will get an option here to download this file, so you can download it. We are also going to use P tata.XLS for Power Query. You don't need to download these files; you can download for understanding the data, but I'll tell you a technique using that you will be able to use these files without downloading. Now, for understanding of the data, you can download these files. Some of the users have complained last year that they are unable to download from the GitHub. What I'm going to do is I'm also going to give you a Dropbox link into the description form where you can download these files. Download of last year's data is available here, and for this year also I'm going to load the PB as well as the PPT used for the video. CSV files are available here, and some of the icons which I'm going to use in the video are made available here. I will add the GitHub link also in my description so that you can download the data from there. Before we move forward, let's understand what is there in Sales Data Used in Video, which is the primary file we are going to use. Let me give you the overview of the data which we plan to use first. This data is the one which will be used as the primary data throughout the series. This is a perfect star schema which already contains fact and dimension tables. So first dimension table which I have is the item table, which contains item ID, name, brand ID, category ID, subcategory ID, brand, and subcategory. So the first table which I have is item table, and item table contains columns like item ID, name, name, brand ID, category ID, subcategory ID, brand, category, and subcategory. As this is a dimension table, Item ID is unique and would be used in my sales fact, which I'm going to show you a little bit later. The second dimension which I have is a customer ID contains customer ID, age of the customer, city, state, and name of the customer. City and state here are the city and state of the customer; customer's address. It is not where customer is ordering; its data customer may be in travel while it is ordering or ordering for the relative, so this is not the same; this is the customer's master data. The third dimension which we have is the geography table; it contains City ID, city, and state, and this is the order city or the sales city uh which we have in the data. Now let me explain you the fact table. The fact table is a retail sales data; every line represents a single order only, means every line contains only one order, and one order doesn't have multiple lines, and this is my sales table, sales fact which I'm going to call here for this is this is sales table; all the sales facts for our current analysis, and it contains order number, the order number which is unique for each line, item ID repeating referencing item dimensions, sales date, on the date on which the sales has happened, delivery date, the date on which delivery has happened, customer ID referencing the customer master table or customer table, City ID referencing the geography T table, quantity which has been sold for each line, price which is size of that particular item on that date, cost what cost we are inquiring for that, and discount percentage. As you can see, we have not calculated the gross amount, the net amount, the discount amount also. The discount percentage is an absolute number; it is not .12; it is actually 12. When we are doing the calculations, we need to take care. Now, in this data, what we have to do is we require some of those calculations, and those calculations will be done either as a calculated column, which is at the row level, or as a measure, which is basically aggregated level, which we will understand in some time in Power BI. So what kind of analysis we want to do on this data? In this data, we can do many analyses like I can find out my top cities, top customers, top brands, top categories, top subcategories. I can analyze where I'm getting more discount or margin; for which item I'm getting that; for which cities I'm getting better discount; on which cities by giving less discount I'm getting more margin. All these kinds of analysis we can do using this data. Now, because it's a learning series where we run the feature and then implement it, might not be possible for me to explain all the possible outcomes for this one, but at the end we will try to create a report to give meaning to this data and we will publish it for our ad user. Let's now talk about the type of data loads. Before we bring in the data into the Power BI Desktop, usually we talk about three modes: import mode, direct query mode, and live mode. But with the emergence of Microsoft Fabric, we have got a new mode which is also known as direct click mode. Import mode: in which in case of the import mode, you actually load data into the Power BI, and Power BI is going to keep the data with it, and on that data we are going to build a model. So Power BI is owning the data, the model, the relationship, the measures, and then you publish such models on Power BI service. When we publish the file, there are two files created on the Power BI service: one is data set file and another one is a visualization file. The data set file or what we now call as semantic models contain the data as well as the model information, major definition, etc. In case of direct query, we usually connect to the databases which are typically RDBMS; not all the RDBMS are supported; there is a list available on the Microsoft side which all databases are supported for direct query. In case of direct query, Power BI only owns the semantic model or your relationship, your measure definition, your calculated columns; it owns that. When you publish this, you will get a data set file or semantic model file onto the Power BI service, but that will not contain data; it will only contain the model information. In case of live query, the live doesn't mean the real-time data; it is basically when you use SQL Server Analysis Services or Power BI data set as a source. In such cases, what happens, the model, the semantic model or the data set owns the data, and that is not owned by the Power BI; that is either owned by a previous Power BI data set or SQL Server Analysis Services or your Analysis Services. In Power BI, we only create visualizations; yes, we can also create some additional measures if required. When we publish such files, we don't get a semantic model or the data set on Power BI service in case we are publishing a file which is connected to a previous Power BI data set. So so the new report or the visualization file will also point to the same data set. Direct lake is the new mode which came in; it provides you best of the import and direct query mode for Microsoft Fabric lake houses and warehouses. Semantic models for Direct Lake: Microsoft has done changes in the Analysis Services so that it can query the Delta par
Format files and give you an import mode performance. So whenever you are going to use Microsoft Fabric, you need to ensure that you are using Direct Lake mode. There are times when it falls back to direct query, and you should try to avoid such cases where it can fall to direct query because Direct Lake performance cannot be compared with direct query performance.
Let's load the data onto the Power BI Desktop. I have opened the Power BI Desktop again, and the time has come that we import the data onto the Power BI Desktop. Out of the modes which are import mode, direct query, live, and directly mode, we would like to use the import mode here.
Now, those of you who have downloaded the Excel files, I'm going to tell you how you are going to load the data, and then I'll tell you, those of you who prefer the URL mode, how you're going to do it. So those of you who have downloaded the data can use the Excel option under the Home tab to upload the data to the Power BI Desktop. The same option is also available in the Get Data, and if you click on the More, we can see what all options we have on Power BI Desktop. We have more than 200 plus connectors for Power BI Desktop to connect to various sources. These are categorized under file sources like Excel, TCH, CSV, XML, JSON, file folder, PDF, databases, most of the common databases like SQL Server, Oracle, IBM Db2, IBM Netezza, MySQL, PostgreSQL, Cbas, Teradata, SAP Hana, Amazon Redshift, and many more, including the most common like Snowflake. Also, we have Amazon Athena, and we have a few other connectors, Microsoft Fabric, which has been launched in May 2023 and generally available from November 2023. The connectors are available for semantic models, data flow, Dataverse, warehouse, lake house, and equ databases. Power Platform connectors for Power Dataflows, Data Services, data and data flows. Azure connector for Azure SQL, Azure Synapse Analytics, Azure Database Services, Azure Blob Storage, Azure Cosmos DB and Data Explorer, Azure Data Lake Gen 1, Azure Data Lake Gen 2, Azure HDInsight, Azure Databricks, and other Azure services. Online services, we have so many of these, including SharePoint Online, Microsoft Teams, Microsoft Exchange Online, D365, etc. And we have a few other connectors which include the web connector, and one of the connectors we're going to use when we're going to bring in the data from GitHub.
Now, those of you who have already downloaded, for them, go to the Excel workbook, search out where your data is. My data is inside the Power BI data, and there I have a data used in video. And once I select, say, data used in video, I can press the Open button to get the data. Once I click on the Open button, it will show me a popup, and in the popup, I can preview my tables. But unless I press this check box, I will not get the data on the Power BI Desktop. We can check all these four files; this has the same data we have explained a minute back. Also, if you have a few tables in your Excel, mark as a table; you will get those here. Now we have two options: to Load Data and Transform Data. When do we use Load Data, and when do we use Transform Data? In case we don't want to transform this data—this data is in final shape, which is true for this data—we will directly use Load Data. But if this data requires transformation, or this data is too big, we want to reduce it before loading, we will use Transform Data. In the current case, the data does not require transformation; also, the size is not so big that I have to reduce it before loading into Power BI Desktop. So I'm going ahead with the Load Data option. I can click on the Load Data, and it will load the data. So this is the option for those of you who are using Excel. Those of you who wanted to use GitHub, first of all, go to the GitHub and find out the URL which you want to use. To get the URL, scroll down, open this file, says data used in video. XLS. Now, some of you would like to take the URL from the top, but don't do that. Go to this button, Raw; don't click on that; right-click on this button, use Copy link. Once you copy the link, come back to your Power BI Desktop, and now use the Get Data web option. I've already shown you all the option categorization, and here you can put this URL. You can check out the Advanced option, but right now I don't need to, so I can continue with the basic option. Press on OK; it should open the same popup again which I have explained you while I was loading the Excel file. I click on the check boxes to make sure that I'm loading the data for all these four tables. It does not mean that you have to load the complete data in one go; you can load data in multiple goes also. I'm going to press the Load Data in this case and load my data. It will show me a popup for the data loading, and this is also one of the ways when you can check the data is loading. It is in import mode because it's going to show you the amount of data which is getting loaded. Data is loaded onto the Power BI Desktop, and on the right-hand side data pane, you can see the data tables. Those tables are Customer, Geography, Item, and Sales.
Now we can go ahead and take two steps from here: one, we create the formulas which are missing in the Sales table for analysis; or second, is we create the model. We are going to create the model, and post that we will try to understand a little bit about the DAX formulas, and that is where our technical stuff will start, where you need to understand DAX and how you can quickly create calculations which can be categorized either as calculated column and measure. Data is loaded, and I would like to create a relationship before I do that. I would like to have a quick view on the data using the table view. On the left-hand side, I go to the table, and as it is import mode, I should be able to see the data of each table below here. I should be able to see the count, and I can match this count with my Excel data, how much rows I have there versus how much rows I have here, to make sure that we have the same amount of data what we have at the source. I can click on Geography to see the Geography data; I have 100 rows there, Item 55 rows, and Sales table having 30,000 rows. All my data is correct. Let's now create the relationship on Power BI Desktop.
Now let's jump onto the Model view, and here we are going to create the relationship. But what we observe, the relationship is already there, and I explained you, let me show you again. Under the File options and setting options, we have an option in the current file, Data load level, which is Auto detect new relationship; that is causing this. In case you are creating a really big model where you don't want to do this, you can uncheck that. Let me close the property and the data pane and try to understand if these relationships are correct or not. So let me showcase you what is the exact model I need on the PowerPoint slide. So just an overview of the model which we are going to create here, which is available in the Excel file which you have seen, is that we are going to have a Sales table which is at the center, and it will have Geography Dimension which is available in the Excel sheet, Item Dimension again available in the Excel sheet, and the Customer Dimension again available in the Excel sheet. We're going to create a Date table in the Power BI Desktop and going to utilize it. It's going to be a perfect star schema where fact is related with Dimension, and Dimension is related with fact. In a perfect star schema, the two Dimensions don't have any relationship between them. So although I have City available in both Geography and Customer, they will not have any relationship between them. So they will not have any relationship between them because in a perfect star schema, Dimension don't join with any Dimension, fact don't join with any fact. So we will utilize this model for most of our discussion, but yes, there would be places for some of the examples this model cannot be used, and that's where we are going to use very specific files and specific tables or the models to achieve those objectives.
Now we have looked at the model; we know this model is not as per our expectation. First of all, there is an inactive join, and we need to understand why there is an inactive join, and we have to also understand what are these different kinds of joins, why there's a one on one side, and why there is a star on one side. So the relationships which are showing one and star, they are one-to-many relationships, and these are the kind of relationships we want in this kind of schema. The inactive relationship here is because of a loop. What is the loop here, or what is the two path here? The relationship here which is inactive is because of the loop or the two paths. Table is joined with a Customer table one-to-many, and again there is a one-to-many relationship with Sales table. It means this is the first path; Geography can reach to Sales; there is also a direct path where Geography can reach to the Sales, and in this manner, there are two paths which are created, and because of that, one path is inactive. Let me delete these relationships. I'm going to delete some of the existing relationships also because I want to tell you how to create a relationship. We have a few options to do that, and let me delete all of them to create a relationship for you. You can drag the table wherever you want to have a position where you can easily map the tables. Now, the easiest way to create a relationship is click on any of the columns, keep your mouse button pressed, and drag it on the corresponding column on the other table. So I am dragging Customer ID of the Customer on the Customer ID of the Sales, and it created a relationship. It did not ask me what kind of a relationship because it has identified, but let me double-click on this and show you on the popup also. On the right-hand side, in the Properties pane which I have already open, you can see what this relationship is, but let me double-click and show you in the popup. In this popup, we can also change the relationship column if required. The Sales table is on the top, and the Customer ID is selected; the Customer table is at the bottom, and the Customer ID is selected there, and it is many-to-one. What does this kind of relationship mean? Many-to-one means the first table is having on the many side; it means the Customer IDs can repeat there. The Customer table is on the one side; it means the IDs are not going to repeat there. In case, in the future, it repeats, it may error out; it may not also work. If you have a blank value in the Customer ID of the Customer table, it is fine; you can have the blank on the Sales side. The relationship direction is single; it means the Customer table, the table on the one side, is going to filter the table on the many side. You're going to create one relationship as both understand that what are the other kinds of relationships. One-to-one means both the tables are having the data at the same level; it means I join Customer table with a table, let's say Customer 2, which both is having Customer IDs unique. In that case, I will have a one-to-one relationship. One-to-many means if I have the Customer table above and the Sales table below, it would be one-to-many; it is just the reverse of what we currently have. Many-to-many means just like Sales table, we have another table where the Customer ID is not unique; both the sides there are multiple values. We create many-to-many relationships, though we avoid many-to-many relationships in most of the cases; they're especially useful in a few of the use cases, and one of such use cases is row-level security. So while we try to avoid many-to-many relationships, it is also helpful, and Power BI handles many-to-many relationships pretty well. So let me click on OK after using that and make the relationship active; it means this relationship is going to be active in Power BI. You cannot select more than one column; so if I try to click on this using Control or Shift, I will not be able to do it. It means we create a single-column relationship, but to create multiple-column relationships, you can create a concatenated column to create such a relationship. In case of direct query, you have been provided a function which you can use, which is Combine Values, to create such a concatenated column. You can create more than one relationship, and one relationship can be inactive between the two tables, and we can use a function, USERELATIONSHIP, to activate such a relationship. Let me press OK. Now the second relationship, I want to create from a different option; the option is in the middle of the screen, which is Manage relationships under the Home tab. Let me click on the Manage relationships, and here you see a popup providing me all the options. One of the options which I have here is New, and I'm going to use that to create my relationship. Let me click on New, and let me select the table. This time I'm going to select my Item table as the first table, then I will select Sales table. Now it has automatically detected Item ID versus Item ID; I don't need to even click and check those; it is a one-to-many, single-directional relationship; this is what I want. The table having the unique values of the Item ID is on the top, so that is why it is one-to-many. Again, I want this relationship to be active, but I'm going to make this relationship as bidirectional. Both, let me click on OK. Let me close it. The third relationship, easy, I'm going to drag City ID to City ID to create it, and on the right-hand side properties, you can see, in case you want to change something, you can even change the relationship, let's say some other column if needed, but as we know the relationship is correct, City ID to City ID, and this is single-directional, and we want an active relationship, so we will say Apply changes. You can also open the relationship editor by clicking on the button below. Let me press Cancel. So my model is ready. As a next step, I would like to understand the difference between a single-directional join and a bidirectional join, and we would also like to understand what happens when there is a missing relationship. For those two examples, let's go ahead and try that out.
Our Power BI model is ready, and here we want to understand the difference between a one-directional relation and a bidirectional relation. To understand this, let's go ahead and create a few table visuals. Now, to do that, first of all, we have to go to the Report view. On the left-hand side, the first button is Report view. Here, because I have already enabled the build visual, I'm able to see this; otherwise, on the Home tab, you will see these options. In case you don't see Build a visual, you can go to the View and enable that from here, Build a visual. Now let me click on the Table visual inside Build a visual. Once I click on that, I'll get a Table visual. I'm going to copy this visual three times and put them separately. Now let's look back at our relationship. So Item is bidirectional, and Geography is single-directional; Customer is also single-directional. I create one visual using City ID only, City ID. I'm bringing in the second visual; I am bringing in Item ID, and in the third visual, I am bringing in City ID from the Sales table and Item ID also from the Sales table. So first table, there is a City ID from the Geography table; in the second visual, I have Item ID from the Item table; and in the third visual, I have City ID and Item ID from the Sales table. I have knowingly kept it on the ID so that you can easily understand what's happening here. So let me click on the Item ID in the second table, and as you can see, it has filtered the third table; there's no impact on the other dimension table. Let me click on the City ID, and as you can see, the City ID also filtering the table visual. As I have not pressed Control plus click, the moment I clicked on another visual, it takes out the filter from the second visual and it applies the cross filter. Let me go ahead and click on City ID again; it will remove the filter, so I will have all the cities, and I have all the Item IDs. Let me click on the first row of the visual which is coming from the Sales table. What you can see here is while the City ID from the City table has no impact, but Item ID is getting filtered here when I'm filtering this. This is because the join is bidirectional. A bidirectional join means fact can filter Dimension, and Dimension can also filter fact, or both sides of the relationship can filter each other, while in a single-directional relationship, the table on the one side, which is Dimension, can filter the many-side table in fact.
Now let's try to understand what happens when there is no join, or how do we identify there is no join. Let me delete all these visuals on this, and let me bring in another Table visual, and this time in the Table visual, I would like to bring in Item Brand. So the way to bring in is that I, once the table is selected, I can click on that; it will bring in, and then I'll bring in quantity. By default, it should take aggregation; as you can see, it is using SUM of quantity. So numeric values are by default aggregated. You have to understand in Power BI, the data is either distinct or grouped by and aggregated. So even though my Item IDs are repeating in my Sales table, but if I put it from the Sales table, they will not repeat here; they will just create a distinct combination or grouped by, and then if I put an aggregated measure or a numeric measure, that can aggregate that will aggregate along with that group by. As you can see, these values are different, and this is actually my total. And now let me go ahead and do one thing which will tell you how do you identify a missing relationship. What I will do is I will go to my Model view, and inside the Model view, I can delete this join between Item and Sales table, or I can deactivate it by using Make this relationship active; I can uncheck that, and it will become inactive, and use Apply. This is as good as not having a filtration, and once I go back to the Report view, you will see that all the rows have the same data. When all the rows start showing the same data as grand total, there are chances that we have an inactive relationship or the relationship itself is not there. The good thing with the inactive relationship, which is a logical inactive relationship or inactive relationship which is not created because of a loop, we can activate it using the USERELATIONSHIP DAX function. In this manner, you now learn how to use bidirectional relationships and how you can find out when there is an inactive join. Now is a bidirectional relationship a good thing? So when should we use a bidirectional join, and when we should not use bidirectional? So bidirectional joins are especially helpful if you want the Dimensions to get filtered when your fact data is getting filtered, but when you start using more than one fact, so in case you have more than one fact, it can create loops for multiple paths. What would happen? You will be able to reach a fact from more than one place. Let's say you create, go to Dimension to fact bidirectional, another fact is again bidirectional, then there are multiple paths available. In such cases, you start creating inactive relationships. We should try to avoid this. One more place where you should avoid is basically when you are using direct query. Now what happens in case of direct query? There are queries which are generated and sent to the source. Now when you have bidirectional joins, it will generate more numbers of queries, and in that will put a lot of strain on your source database. So to optimize the performance in a direct query mode, we try to avoid bidirectional relations. So bidirectional relationships should only be used if that is the only way you can solve the purpose; if there is no other way to achieve.
The same thing, like I want to filter the dimension data using fact, we can actually use in the slicer a measure from the fact and check its value as is not blank to filter the slicers to reduce the slicers values what has been used in fact. That is another alternative, but if there is no other alternative by directional joint is only fit for the purpose, then only we should use it. Now, before I go to the next step, let me go ahead and activate this relationship and apply changes so that our model is correct. As you can see, once I have activated the join again, I'm able to see the correct data.
Before I take the next tab, let's do one thing: let's add an image to this first page, the image of this series, and then save this file. Because we have not saved this file, so in case the system crashes or something goes off, the changes might not be fully recoverable, though we have used an option auto backup that may be able to provide us autosaved version which we can use. I click on this empty page; let me click on the format option and enable the format pane. Once I get the format pane in the Page information, I can scroll down and in the canvas background I can browse an image. I can take the image which I recently downloaded it and reduce the transparency to zero; image fit is normal. I can use a fit so that it fits in, and in this manner I get my homepage with the image which is my image of the series.
Now you might be seeing this build visual is still there. Now, prov that what I can do is I can add something really small in this page, so I can go to insert and then I can, let's say, insert a shape; let's bring in a rectangle, and let's do one thing: go to the style, fill off, border off, and come outside. Now you don't know there is a rectangle, and you get the image. So let's save it, Ctrl+S, give it a new name; uh, it's going to save on a default location, and if you want to change that, click on the more options below. Once you click on the more option, it will open, and now it is showing me documents on the top, but if you go on the left-hand side little bit below, you will see browse this device. Let me click on browse this device. Now it opens up option, and as you know that we save all our files in data, but not this time; we're going to save the file in our end-to-end, and I'll also create a new folder for that. Right-click in that new folder; we going to call it data. We don't have a data here, but we have a PB file, and I'll give it a name as N to and.
And what would happen during this series? There would be movements where I, I need to stop and start a new file; maybe I don't want to use it, or I want to save it a particular place because I want to modify certain other things, or it is too busy file at that moment. I may like to shift it, especially when we are going to go to the power query learning; we might not use these tables. When we try to create the final dashboard, we might not require it, so at that time we might create a one more version of this file. So to do, to create the scope for that, I'll call it N to and one file, and let me save it. Now for saving, now I have three options: PB, which is power BI file; PBIX, which is the template file which was also available previously to create the template; and Power BI project file, which is a new option available with the GitHub integration. This is one of the most suitable options you have, but we will continue to save it as a PBIX and save it.
So now our Power BI file is saved. Before we go into the depth of calculated column and measure, one of the reason we say is that you know when we want to do row-level calculation, we can prefer columns to, you know, make sure that it increase the load time, and if the data is pretty large, the runtime calculation at the row level could actually proven be costly. But if it is not costly, then go ahead and create a. Now what is this row-level calculation, and when would I use row-level calculation and when I should not use row-level calculation? There are few places where you can simply take this decision that I need a row-level calculation whether at the new calculated column level or measure level, or whether I don't need it. There is a place where I should not do row-level calculation; I should create a measure, or what is that kind of scenario? So when whenever we have to multiply, we have to use the row-level calculation whether we use calculated column or a measure, but when it's a division, the division should always be first aggregate and then divide it. It means it should be a measure. Let me give you one example for that. So I have these items; I have quantity and price. Now what is gross? Quantity multiplied by price is basically this formula. So this is 50, 70, 80, and 90. Now, so I'm multiplying at each row level, and then finally I'm summing it up here as 290. Is this is correct, or should I simply sum of the quantities, average of the price? I definitely know if I sum of the price, it's not the correct, so it's going to be 70 * by 4.75, which is 332.5. So which one is correct? We know here 290 is the correct answer; it's not 332.5; that's not the correct answer. Whenever there is a multiplication, we should do it at the row level, and then we should add, which actually we call it sum of a multiplied by b means false; you multiply. Now in database we can do this sum of a * by B inside the sum function; that is not true in Power BI when we creating a measure, and measure is one where we do have aggregation built in there; we need to use expression function to do a multiplied by b, or we can create a calculated column which contain a multiplied by b, means in this case cross, and later can create a measure on top of it.
Now there is a reverse case; the reverse case is when I want to find out price using gross and quantity. So how do I find price? So simply I'll divide gross by quantity. So I got five, I got seven, I got four, I got three. What's my average price? My average price is nothing but the total of gross divided by total of quantity; it is not the simple average of these four, which is 4.75, which is a simple average of these four; it's not 4.75; 390 / by 70 is 4.14. This is my correct data; it means whenever you need to divide, you first need to aggregate, means sum of a divided by sum of B. So what does this means is in case of division, it should be sum of a divided by sum of B is first you aggregate and then you divide. So in such cases we should only use measure because calculated column is going to do the calculation at row level, and post that the aggregation can happen in a measure, but in case of measure we can aggregate them separately and then divide, or in the same measure we can say sum of a divided by sum of B table and column. In this manner, in some of the cases we can take a call where should we use a measure or where should we use a calculated column. Remember on a smaller data where the row-level calculations can be done in a measure and not making much impact, we can still use measure for row-level calculation, but yes there would be some time because of the performance region; we will prefer half of the calculation in calculated column and then use measures need to create calculations, and these calculations are divided into two parts: calculated columns and measures. Now calculated columns do the calculation at the row level and they are stored in the data set semantic model or the file. All the calculation you are going to do, you will be able to see what new values are getting calculated into the table view, and you will also be able to see that when we save the file, the size of the file increase. On the other hand, the calculation done using the measures are only definition and getting executed at the run time.
The calculated column which we would like to create right now are gross amount, which is nothing but sales quantity multiplied by sales price. The second one which we want to create is discount amount, which is nothing but sales gross amount which we already calculated multiplied by the discount percentage. Now discount percentage here is an absolute value, so we have to divide it by 100; gross amount multiplied by discount percentage divided by 100. And one more column which we wanted to create is COGS amount, which is nothing but sales quantity multiplied by sales cost. Once we reach the measure, I'll explain you what all measures we need. I on the Power BI desktop, and from this itself by going to the data view, I can create new column. So I can click on the sales table, and in the table tools I will have option for new column, but but I have an intention that when I create calculated columns, calculated columns are getting added up to the tables and will be saved along with that table, so I would like to see the values getting generated, and that is why I'm going to use the table view to do that. So let me go to the table view, and before I start creating my new columns, I would like to note down the size of my file so that at the end I will able to tell that the calculated columns are getting saved along with the data table and they are adding up to the table size, and measures are not going to add the size; they are just definitions. So let's note down the size right now; we have 1,623 KB size for this file, and after some time you're going to come back and check this after we have created our calculated column and saved the file. So now let's start creating new calculated column. I have told you about the table tools; once you click on a table, you get table tool new column option, but the option is also available in the column tool. If you click on any of the column, you will get column tools, and in column tools also you have option for new column, or right-click on any of the table; the second option is new column; right-click on any column; third option is a new column. Using any of these options, go ahead and create a new column. In the formula bar above, you can see the column creation. So you can see now the formula bar where we can create the new column. Let me go ahead and increase its size; I have press control and used the rolling of the middle mouse button to increase the size. Now I got the column; it has two parts: left-hand side is where we I'm going to give the name, and right-hand side where I'm going to give the formula. These line numbers are not going to play any role; Power BI is going to automatically add that. So the first column I want to create is gross amount, and what is gross amount? It is quantity, and it starts suggesting you can use that; it's always better that you take complete table name, column name. So let me type down the table name, sales quantity * sales price. So we should always take fully qualified names when we are creating the columns. So sales quantity multiplied by sales price is the gross amount. As you can see in each and every row, the data has been created, and the column values are visible in the table view. You can also see this column added on the right-hand side into the table with an icon which is showing this is a calculated column. Now let's press commit here or enter; it will come out. Now let's go ahead and create a new column; you know all the four options I can see column tools open in front of me, and I'll click on new column there and add another column. The next column I want to add is COGS amount, and COGS amount is nothing but sales quantity multiplied by sales cost. Now finding out a cost of item is a really big challenge for some of the organization. If an organization can achieve a cost measure, nothing like that, and COGS is not just purchase price; it's purchase price plus rate plus inventory carrying cost and any other cost you wanted to load on the purchase price to get the cost of the item. Various organization develop various kind of methods to arrive at the cost of the item, and that's from that we are calculating COGS so that we can get margin. I would like to create another column, and again I'm going to use new column from the column tool, and that is discount amount. Now discount amount column needs the calculated column gross amount, and I can type sales gross amount to get the gross amount. So table name shown as a table name, and sometime you will show see the table name is coming in single codes; if the table name contain white spaces or a reserved name, it will come in the single codes; otherwise it can come simply as a table name, and in the square bracket we have the column name, multiply it by sales discount percentage, and as the discount percentage is absolute, I need to divide it by 100; it should become decimal number. So as you can see the data type, and let's talk about the column tool. Now here in the column tool we can see the name, the data type, the decimal number, the format which is generic, and then we can say it's amount; we can use dollar symbol or any other symbol, percentage, comma separated; we can change the decimal place and number of decimal place; right now is auto. Similarly we can use the summarization which is by default sum for the numeric column; if you don't want to summarize it by default, we can use none. Summarize data, category data; category data is especially important when we use geographical data. I'll go ahead and show it to you. Sort by column is required when, let's say, if I have column like month here and I want to sort it on something else, I can use sort by column, which is not needed right now; we will use it when we create the date table.
Before I go ahead and create my measures, I would like that if there is any renaming required of the tables and column, I should go ahead and do that. So as you can see in the customer table, there is no renaming required; geography table, there is no renaming required; item table, there is no renaming required; and sales table also there is no renaming required, but for you to explain it to you, let me go ahead and rename this column Quant Qi. And I already created calculated column on that; now I want it to rename, so I can double click and rename, or I can right-click, CCK, or rename. Let me call it quantity, and let me check the new columns which I've created; have they taken up the correct column name or not? So the gross amount column has already taken up the correct name. Same way I can rename my tables geography, item, and customer if required. Column tool is the one place where we can change these property; the another place where we can change the properties is the model view, and inside the model view the properties, we can also change the properties, and here we can see the properties like name; we here we can, I can change the name, then snow names, hidden; if I want to hide, data type, percentage format, thousand separator, yes and no, decimal places, and in advance it will show me sort by column name, data category, and sum. Now I would like to change the data categories; would like to show you example of data categories. I will go to City column; I'll scroll down and show you the data category, and here I'm going to call it as City. Same way for State, I will go ahead and I will define the data category as state or province. It is not that this is available here; if you go to the report view or the table view also, you can go to the state and inside the data category of column tools also you can define the data categories. Now we are done with the renaming and the column creation; we have created our columns. I would like to save this file and see is there any difference in the size of our file, so let me drag back the folder, and as you can see the size of the file has increased. In this manner we can conclude that calculated columns are going to become part of the table data; they will be calculated at the load time and will be saved inside the file and going to increase the size of the file; they're also going to increase the load time. Now we will understand the measure, measures, and then look at the difference between measures and calculated column.
The time has come that we should go ahead and create measures. Let me tell you the definitions of the measures which I plan to create. The first measure I want to create is gross, which is sum of gross sales amount from the sales table. Second measure which I want to create is the COGS, sum of sales tables COGS amount. Another measure, discount, sum of sales tables discount amount. Then I'm going to use the measures which are already created to calculate net, which is nothing but gross minus discount. Same way I'm going to create margin, which is nothing but net minus COGS. I will create two measures which should be measures only because they are percentage measure and they need to be calculated using divide function which handles the divide by zero: discount percentage equals to divide discount by gross and margin percentage equals to divide margin by net. So these are all the measures I'm going to create. So let's go to the Power BI and create these. So now let's go ahead and quickly create the measures, and to create the measures, uh, let me first go to the table view and try to create a measure, and can I see the calculation just like calculated column in the table view? So let me create my first measure. To create that again I can take the help from the table tool; I have an option for new measure also; I have the same option in the Home tab for new measure also, on the right-click of a table or a right-click of a column. Similarly, once you create a measure, you will also have an option to create a measure. Right now I'm going ahead with the right-click on a table and new measure. Again in the case of measure, we will get this formula bar where left-hand side is the name and the right-hand side is the formula. This is what we call a measure or a DAX measure because we are going to use Data Analytics Expression here to create our measures. So first measure which we are going to create is gross. In the gross measure I'm going to use the DAX function SUM. SUM functions can take one column name, and the column name which I want you to take here is sales gross amount, and this is the reason I was adding amount at the end because finally when I create a measure it should show me name only as gross. As you can see the gross measure is created in the sales table, and I can see the measure icon, but when I scroll into the table it's not appearing inside the table. So measures will not appear in the table like calculated column. Second thing is even if I click on the item table and I, I go ahead and use new measure and this time I'm using it from table tool, it would be able to create a measure. So this time I'm going to create COGS equals to SUM of sales COGS amount. So I'm creating a measure COGS which is nothing but sum of COGS amount, and as you can see I'm able to create this measure inside the item table. Does it make any difference for me? Let me go back to the report view. In the report view, from the bottom near to the page one, there is a plus button; I'm going to press that plus button and add another page, and in this page, and in this page from build a visual, let me add a table visual, and check out what I'm getting. To do that, I created a table visual, enlarge it, and let me bring in brand from the item table, drag and drop onto this visualization, and bring in gross and COGS, and you can see both of them working fine. Now, without going back to the
Table view. I can continue to create my Majors here. So the next major which I'm going to create is Discount major. So click on any of the table and say use new measure from the table tool, and name is—and let me enlarge it—discount, which is nothing but sum of sales discount amount.
The next major I would like to create is net. And then in the net majure I would like to create from the two existing Majors. So left hand side the name, right hand side cross the major, and I don't need to table name. Ideally speaking, you should not use table name when you are using major because we can change the home table of the majors, and I'm going to explain you that in a little bit of time. And then I can separate the discount, and I created a major which is net. In the same manner I can create a major margin. Again by clicking on new major, and you can press and enter or you can press this commit button to commit this formula. The moment you click outside it gets automatically saved.
Now we would like to create two measures which are division type and now discount percentage, which is Discount divided by gross and margin, which is margin divided by net, which is actually the net margin are the division type formulas, and they cannot be created as column as we have discussed when taking our example. Division should always be a measure.
Now before I do that, let me show you how can I add that these to the table. So click on the table and just simply click on the check boxes, and those will be added to the visualization.
Now let's create one more new major. Again, now I'm able to see the major tool because right now the major is selected, and the major tool is cannot only do a job of creation of a new major, but it can do the formatting also. And right now, right now you can see the formatting is not there, but what I'm going to do is I want to format multiple measures together. Definitely I'm going to show you because the formatting going to be compulsory for the discount percentage from the major tool, but we will go to the data model view and from there we will use the properties to change them in one go. So let me click on a new major again, and this time I'll create a major discount percentage, and I'm going to use a function divide. Divide functions takes three argument: numerator, denominator, and Alternate result. So numerator is Discount amount, which is Discount major. I can directly use a major here, and when I'm using major it means sum of discount amount. Denominator is gross, which is sum of gross amount. So I'm using aggregated one. I don't want to use alternate result. What is the benefit of using this divide function? Divide function will handle divide by 0er, so I don't have to bother about it. Let me press enter or commit, and this will be committed, and I can add this to table user. As you can see this is coming as a ratio, not as a percentage. Just like your Excel you might have used, or if those of you not used, go to the major tool. When you click on a major, major tool should be open, and from there you can mark it as a percentage column by clicking on this percent icon. It should show a boundary here, and this boundary means it has been selected. As you can see we are able to see percentage. And now what I'm going to do is a quick Copy pcee for creating the margin percentage major. I can go here again, click on item or sales, and from the table tools or from the major tool whichever is visible, I can create new major, and this time I'm just going to paste the definition: margin percentage is equal to divide margin by net, enter, and my Majors is created.
So my base set of measure using which I can explain you the visualizations are created, but as you can see these measures are created across various tables, and some of them are not formatted. What I'm going to do for that? So first let me solve the formatting. I have to indiv do. If I go here, I have to individually do. I can can't select with the shift more than one. So for that I'll tell you go to the model view, and inside the model view with the shift or control you can select multiple measures. So I'm selecting all those amount kind of a measures, and let me uncheck the margin percentage. All the amount kind of measures are selected. First of all, I can change their home table. Right now I'm not changing it. I'll tell you the reason later, but I will go here in the format, and I can call them general or currency. Let me keep it General. Let me keep it thousand separator and decimal places. Let me keep it one for all of them. Advance uncategorized, everything should remain uncategorized. Let's go ahead and check what is the difference this action has made in the report view. So I'll click on the report view left side, and as you can see all of them got formatted pretty well here. Now left out is margin percentage. We can go back and do it from model view, or we can also do it from column tools. So we click on the margin percentage, and we can mark it as a percentage format column from here. Now it has become a percentage format two decimal place by default. We can change it if required. Go back to the report view, add this into the visualization, and check out what we are getting. So we are getting a two decimal place percentage number. So in this manner we can modify the major properties using Major Tool or the property pan in the data model view.
You might have noticed that the till now I have increased the font when I was creating the formulas of the formula pane, but I never changed the size of the font of the table, though it's a really small font for recording. And the reason I was not doing is because I want to handle it using the theme. Utilizing report themes allows for comprehensive design alteration across the report. This include adoption of color schemes. It's an implementation of fresh visual Styles. Once a report theme is applied, it sets all default formatting for every visual in your report, ensuring consistent and unified experience. We want to get a unified corporate experience, and the reason why I don't prefer to change any font or color without using a theme because once we change it sometime it is really difficult to apply themes on that, and that is the reason why in spite of having a small font I have not changed it.
Now the theme which I'm going to create is more suitable for the video purpose, but what you should do is if you're doing a customer project or your organizational project, find out top 10 organizational colors and using those top 10 organizational color and your organizational font you should create your theme. Let me tell you how to do that. Go to the view tab on the top, and inside the view you have these default themes. You can choose a starting point like darker or lighter based on your organization preferences which is most nearest, or you can start with anyone. Let me choose this third one. Once I choose that you can see the fonts are still forther smaller. I can play around, choose one which suits best. So I think this this accessable city park is something which is more suited to me, and now I'm going to go ahead and modify this. If I further scroll below, I have options like browse themes where I can browse the theme theme Gallery. I can go to the theme G customize current theme to customize the current theme which I'm going to use now. Save the current theme to save it with a name so that later on I can browse it, and how to create theme to go to the documentation. So let me use customized current theme option as of now, and in this customized current theme the first option which I get is the name and the color where I have the color. Now this team as a name, I can change this name if I want, or I can go ahead and choose some little bit different colors. So what I'm going to do here is I'm going to choose a little bit darker green for the first bar, and let me change this yellow color a little bit. There color seem fine, negative positive and neutral. I'm seeing an opportunity to change it little bit. So let me change the red, green seems fine, neutral let me make it a little bit different blue, and Divergent color I am fine with that. I go to the Advance. Now this is really important. Choose the different elements of your visual like XIs grid line, text box color, font, what are those in each categories for that. Click on this learn more, and it's going to open a page for you, and in this page this is basically the theme page which I'm also going to provide to you. If you scroll down little bit below, it is going to tell you if you change the first level what is going to change: label background color, trend line color, text box default color, table and Matrix values and total color, data bar access color, card data labels. These is going to second level is going to change light secondary level text classes, label color, Legend label color, exis label color. Third level: X is grid line cover color, table and Matrix grid color, slicer and header background color, multi row card outline color Etc. Fourth row: legent dimed color, card category label color, multi-row card category label color, then background is going to change the background color, secondary background color and table accent. There is more information also given here how to set up themes and what are the different components of that. You can take advantage of this particular article. I will also share the link of this into the description. Let's go back. I don't want to change any of these as of now. I'll go to the next item which is text, and here I'm interested in. So everywhere I see a font I'm going to increase It by Five Points. Now I don't want to change the font family, but I have options to change it. Similarly I can change the font color which I'm currently not doing. For title again I'm going to make it little bit larger 17, and let me change the title color. Let me make it blue, make it a little bit darker blue which is going to be very near to Black. Cards and kpi again card is 45 is to already pretty big so I'm not going to change it. Tab headress I'm going to make it as 70, and the reason I'm increasing it by 5 pixel you might not have to do that much is because I'm recording a video, and in that video I would like these things to be visible. Visuals background I don't want to change. If I want I can increase transparency to 100% of the visual background so that they take the background color. It is mostly useful when you have a background which is of darker color so that you make all your backgrounds as transparent so that they can come on that particular back ground and you don't have to set a background for the visual, but if you don't want that transparency keep it 0%. Borders, borders are off, but if you want borders by default on the visualization you can switch it on. I don't want that by default so I'm keeping it as off, and if you switch it on you can change the color and you can also decide the radius. Header, header background color, border color, transparency uh if you want 100% transparency you can use. Icon colors I'm not going to change that. I'm going to keep it as is. Tool tip is the label text color, label text value, drill text, icon and background color. This is something which these days we are going to use white, but if you remember earlier we used to use little bit yellowish color, so I'm going to make the tool tip little bit yellowish. Page wallpaper transparency I think I already changed transparency at one place, but I'm going to keep it as is. Similarly P background transparency is 100%. If you want you can make transparency is zero so that it takes the whatever is there on the background. Let me leave it default as is. Filter pane, the filter pane which is being given on the page on these things, these are going to apply the filter pane, the background color, the transparency, the font and the icon colors. The title font I'm going to increase it to 17. Header font size I'm going to make it as 14. Checkbox apply Color when you apply something on checkbox you want to CH that color. It's right now the teal color. I'll continue with that. Available filter cards color format filter cards haven't been applied yet. Background is white, transparency is 0%, font and color icon color it same, and I'm going to make it 14 in the font. Filter applied card again I'm not going to change anything there. I'm just going to change the font size. So I'm done with my changes and let me apply, and the moment I apply it you can see the font size have increased. If I need further bigger font I can go ahead and do it, but it seems good enough for me to use it as of now.
Now the next step is saving this theme. We will go back to the view again, open this theme portion, go down and press on save current theme, and let's call it as or theme one. So the theme is saved. How do we test this? So let me go ahead to the files open, and I have saved one file other than this end to end. Click on it in the versions. I'll open this end to endend version till columns. In this file I'll add a visual, and in that I'll try to apply this theme. So let me create a visual quickly here, and let me go ahead and put a theme. So how do we do that? Go to view, down arrow key on the theme, browse the theme. This time this time I'm browsing the theme in the data. I have a theme 1. Json. I'm going to select that. Once I come back and this theme is applied, I get a message: file successfully added. I can press got it, and as you you can see the theme has changed the font size and other things would have also changed. Now as we progress further into the visualization we'll see impact of those.
Now we will learn how to enable the dark mode. We are going to look at the settings to enable the dark mode which has made its way to September 2024 release. So let's jump on to the release note first, and this is powerbi set September 2024 feature summary, and if you scroll down one of the first announcement which you can see is that you can now choose from a variety of themes powerb desktop including the most requested Dark theme. You can personalize your data visualization experience to match your preferences and working environment. If you further scroll down you will see IND the content in the journal by popular demand dark mode is now available on powerb desktop, and when you click on this you will see how to enable it. So you have to go to options and settings, Global reporting setting and personalization. So let me showcase you that, and while showcasing we will take two kinds of file: one which is using a dark theme on the visualization and one which is using lighter theme in the visualization. So let me showcase my file to you. This is my first file which is using a white theme, and this is my second file which is using the darker theme, and these are the powerbi report themes. Now we would like to change the overall desktop theme. So for that I'll go to file, options and settings below options and click on options. Options popup will open. Inside the options popup inside the global go to report settings, and inside the report settings come down inside the personalization. You have option dark, light, use system setting. So I'm going to use dark here. Click on okay. As you observe all the menu items, the right hand side data Pan, the left hand side pan, everything is now using Dark theme. My model viewer is also showing the darker theme. Now if I go to this file now because I have applied on that file maybe I have to open this file again. Let me open this file again, and this file is already open, but what I can do is basically uh I can open it and you will see this power bi desktop Opening screen itself has changed. Now this file is opening again and it has open on the different window. It will bring it in, and as you can observe that your powerbi desktop is in the dark theme. Now everything which belongs to power VA desktop other than your reporting canvas area which can have its own reporting theme, every everything is using do theme. So do theme has been applied here on all the files globally. You can look at the data view, all your tables, all your icons have changed. These are your icons, these this is your table data view, model view already shown you, Dex query view. Everything Has Changed to darker them. I opened a new file with the dark one. I have closed all my power ba instances which were running before I applied the Dark theme, and I have opened a blank new file with a dark theme where I'm now going to open a blank report. Let me click on the blank report, and now here I would like to get the data, and I can use a powerbi semantic model for that. Let me bring in one semantic model, and we can use this calculation group semantic model which I was using for quite some time. So the semantic model has loaded into the powerbi, and as you can see all the UI you can observe they have been adjusted with reference to dark mode. The model view is in the dark mode, the Dex squarey view is in the dark mode, and we can see all the uis are perfectly fine with the dark mode. So you have seen that we have chosen the dark mode, and the impact of the dark mode is mostly on the menu items. It is not related to your report theme. If you want to change your report theme basically powerbi report you have to still have to go to view, and there you can go ahead and choose use a dark theme, and then your report canvas will also use a darker theme or whatever theme you have selected. So you can have your report canvas theme or report theme which is separate from your powerbi desktop darker theme. That is different from this one. So you can choose whatever theme you still want for your reporting canvas or your powerbi report. So go ahead and explore this dark mode.
We would like to learn now how to create a table visual. Before that let me tell you how to rename a page. So the page name is here in the bottom. You can double click on that and you can change it. So I'm calling it as a main page. Now near to that there is a plus button, and I'm going to create a new page using that one. So I'll click on that, and this is a new page, and let me double click on this one also and call it as table because I'm going to create a table visual on that. To create a table visual either from the Home tab insert visualization I can use it, or I have already enabled the build visual. In case you are not seeing it you can enable it using the view and then further by clicking here on the build a visual. So you should be able to see this pain from any of these places. You can use the table visual. So in the build a visual I'm going to click on the table Visual, and it will add a visual on the page which which I'll click on the visual and drag it down and make it little bit bigger. Once I've done that, if I have clicked on it I can see the check boxes on the data pane which I can click to bring in the data, or if it is not selected then I can drag and drop. So let me drag item brand either on the visual that's First Option, then let me drag category inside the columns which is is below the Builder visual visuals, and third option is because now this visual is selected I can actually go ahead and add some major by simply clicking on them. So you can drag it on visual, you can drag it on the columns, or you can check the check boxes and add certain things. Now what are the options available here with the table visual? So let's have a look at the options of the table visual ual. So first we would like to see the options inside the three dot. So in the three dot we have export data option using which you can export the data into a CSV format.
On the three dots, we have another option: "Use table," which is pretty much applicable for all the visuals. It will show it as a table. In case of a table visual, it is already a table, so we'll continue to show it like that. And there is a button, "Back to report," which we can use to come back to the report. This is especially helpful when you have multiple visuals and you want to see them in a table.
Then the next one is "Remove." We can remove this, which we don't want to do automatically. "Find cluster" is an AI option which we are going to explore later. Then we have the option "Spotlight," "Sort by." We can choose a sort by column, like brand, category, and COGS. And the "Format" option. Right now, you can already see the format pane is open because this is how I have set up my panes. Because of which it's open; if it is not open, you can use that option.
Now let's go back to the sort option. Let me say "Sort on Brand." Now you can see that it has been sorted on brand, on descending. Now I can go ahead here again. I will see the option for ascending and descending, and I can click on "Sort ascending." Right now it is sorted descending. Now, table visual is one visual where we can have multiple sorts. So now it is already sorted. If you want to change it from here, also you can click and change. If you click on the name of the brand, you can see the sorting is changing. Now press the Shift button, and now you can sort the category. But I don't want to sort category by name; I want to sort the category by gross. Let me click on it. So what does it do? By default, for numbers, it sorts by descending, so it is sorted on column one's brand and sorted descending on gross. So first sorting was on brand, and second sorting is on the gross. Double sorting is possible; you can have multiple sorting using the Shift button.
Now, when you click on this, because of the on-object interaction, it starts showing which property you can change. If I click here, which property can change? If I click here? If I click on the header, it started showing the column header text. So in this manner, the on-object interactions allow you to change the particular properties by clicking on that particular set.
Now let me click on the table and let me take you through all the visual properties one by one for the table visual. "Size and style" is the first property. Now you can see the height and width is based on what I've created. And then the "Lock aspect ratio." In case if I use the lock aspect ratio, if I resize the table, it will maintain the same ratio which I've taken currently, which I'm not planning to do right now. "Horizontal" and "Vertical" is the position; it will change the moment I move the table up and down. Next comes the padding. The padding is from the top, bottom. So this is the padding; I can reduce it as per need. "Background." Right now the background is on, and there is a color. I can go ahead and change this color, and because the transparency is 100%, I have to reduce the transparency to see the background color. So the background color is the color which is behind the table. I can increase a little bit of transparency to keep it. If I switch off the background color, there will be no background, and I will be able to see the page background color. I enable it again. The next option is "Visual border." Right now it is disabled. I can switch it on; you will be able to see a border. Now if you click outside—let me click inside it—and let me go ahead and change the rounded corner so that you can understand what's happening there. So now you can see the rounded corners for this table. You can see a border as well as the rounded corners. In case you want a shadow, you can switch it on, and it will start showing the shadow. You can decide the shadow color, and you can decide whether it should be inside or outside, and where it should be: it should be bottom, bottom right, bottom left. Various options have been given which you can choose. I would like to keep it bottom right only; that's the most suitable option for a shadow.
Right now there is no title, but I can enable the title. So let me enable the title, and I can double-click here and give the title. So there are two places where I can do it: I can give a title from here, or I can double-click here in the title itself and I can give a title. So let me call it as "Table Visual," and as you can see whatever I'm typing here, it is also appearing here in the text. The FX means I can use a measure here. So if I need a dynamic title, I can create a measure and I can use it inside it. Right now it is using heading three; I can change it as per need. Similarly, I can use bold, italic, and underline for it. I can use a color; background color is right now nothing; I can choose it again. I can use FX, means function, means I can use measure, and let me showcase you at one place. So if I click FX here, I'm able to see field value, and I can choose what measure I want to display here.
Now there is a subtitle option. Right now there is no subtitle which has been used. I can enable the subtitle, and now I get a subtitle option here again. Either I can type it here, or I can use a measure using FX, or I can type directly here. We prefer on-object interaction; we like to write on the visual. So let's say "Information for brand and category" for subtitles. Again we can choose text colors. Now right now this text color is not matching, so I'm going to change it. Then you can choose the horizontal alignment. Right now it is left-aligned; this one is a little bit darker; I can make it middle-aligned, so it will go into the middle, and to match it also, I'll make the title also middle-aligned. So both title and the subtitles are now middle-aligned. "Text wrap." If there is a larger text, we can use text wrap so that it gets into the next line instead of cutting it down. Then we have "Divider," which is right now off. I can enable it, and you will start seeing a divider between the header and the table area. It is solid one pixel; we can increase the pixel to understand it better. "Ignore padding" is on; if you want, you can disable that. Next is "Spacing." "Spacing" is customized; "Spacing" is off. If you want, you can customize the spacing; switch it on, and let me reduce the spacing, and as I'm reducing the spacing, you can see the impact between the below area and of the above area. Next is "Style resets." Now right now the style is different, FA, and which is the shaded style. If I choose "None," you can see the difference what is happening in this table, and I'm going to use few of these styles and showcase you what all they can do. "Border header" is one style which actually I'm liking a lot. "Alternating rows" this also seems good. "Contrast alternating rows," "Flashy colors," "Border and flashy colors," "Bold and flashy colors," "Bars," "Condensed." I'll keep it to default right now, and based on this, when you go to some of the features, like especially when you want to color the rows, you will get that option of alternating colors. Right now, because it is by default alternating color, and you go to "Grid." So right now the horizontal grid lines are on. So these are the grid lines which you could make a note of it; these are horizontal, and these are vertical. So let me off and on; let me increase the size a little bit; you will be able to differentiate. Similarly, vertical are off; I can on it, and if I increase the size, you can use grid lines vertical and horizontal. It's not looking so great right now, but to explain to you, I have to do those changes. Now I may choose a different color also. Next one is "Border," and let me showcase you. Right now if you notice, there is no border for this particular section of the table, but let me enable it; let me enable top; you can see the border on the top here. Same way, bottom, left, right, and let me increase the width a little bit; you will be able to observe it on all the sides. Next one is "Options." There is a row adding which you can increase, which will increase the padding between the lines. I'm going to decrease that to zero. And "Global font," if you want to increase the font, but we don't want to disturb the font; we would like to continue with the font from the theme.
Now comes the important which is "Values." Now we want to play around the values. "Values" is typically these, these, these. These are called as values. Now you can see that I have the text color and the background color, alternate text color, and alternate background color, and this is because our theme is alternating color, and just to explain it to you, let me change the color so that you're able to make sense out of it. And then alternating text color, let's only change the background color; let's change the text color. Now again, "Wrap text," in case the text is taking more place, we can use wrap text instead of cutting down. So these are the values which have changed. Next comes the column header. In the column header again, this is the area which is going to be impacted because of the column header. Let's make the column header as bold, metallic, and underline. Color I'm fine with that; background color white is also fine, and do I want to make them left-align or center-align? As this is a generic one, I don't want to use; there are better options available to handle it based on each column, so we are going to use that option right now. Let's leave it; let's go to the next option. "Auto size width." Now what happens is if you can go ahead and resize these columns, but what would happen if you do certain changes? This may get back to its original size because of the auto size width. So let's say you use a filter or a slicer, and this may come back to its original size. If I don't want it to come to original size, then what I'll do is I'll switch it off so that once I fix this width, it should not resize, and that's where we can use "Auto size width" off. Then the next option is for "Totals." "Total," we have value values, and we can switch off the totals; we don't want the totals. And if you switch it on, now do I want to call it total, or do you want to call it grand total? Again, static in nature; uh, you don't have an option for FX. Text color you can define, and background color you can define. Then comes the most powerful option: "Specific columns." Now here what you can do is you can choose each column, and for that you want to decide you want to change something which should apply to header, apply to total, or apply to values. Like this is one common question which you ask that for the discount column, I want everything to be same; I would like to apply to header, apply to total, and apply to values. What I want to do here is I want a text color, let's say orange, and I want the alignment as left. So for the entire category column, you can see the text color is orange and the alignment is left, and even for the alternate color it has changed. So this is when you want it to do it for complete column. There is no background color; we can actually go ahead and give a background color, and you now you can see because we, I have given a background color, it is not following that alternative. So in this manner, in case, case there is a requirement that you wanted to have one single column from top to bottom following something, you can do that, or you may would like to say now don't apply it to values; I'm fine with alternating colors; I'm now only applying it to header and total.
Next comes the option of "Cell elements." Now "Cell elements" provide us opportunities for conditional formatting. The advantage in the table visual is that we can do it on all the columns. We have something known as "Matrix visual," where we will not be able to do it on rows and columns. We don't have a concept of rows and columns here; everything is a column here, so we can do it on all each and every column. And just for the showcase purpose, I'll show you one conditional formatting on the background, but later on we will come back and do a deep dive on the conditional formatting. Let me explain you how to use conditional formatting with one base example. So I'll click on the background color, and it automatically opens a popup which we call the conditional formatting popup. It has three styles: gradient, rule, and field value base. I'm going to use the gradient style as of now; that's the easiest one. "Value only," "Values and total," means it will apply to total; "Total only," it will only happen to total. I'll use "Values only" right now. "Count of brand," typically it needs a measure or a calculated column, so I'll prefer a measure which is net here. I'll choose that, and it is from lowest value red and highest value is green. I can add a middle color, but those things we will explore later. And right now I'm going to press OK button to apply this, and as you can see the conditional formatting has been applied here, and we can see different different background colors depending on the net value. We can explore font condition formatting which will happen on the font, icon which will show icons, web URL which will show web URL. The next one is "URL icon." For this you need to have a column which is having URL, and you can convert it into icon; it should not show the URL. So we will use this inside the Matrix visual for that. We are going to add a URL in our item table. "Image size," in case you are using an image, then you can use the image height and width. The image size will only be applicable when I have the image. Right now I don't have image, so we will take back these URL icon and image icon later. We have certain images which we wanted to show in visuals, and we'll take this up later. "Accessibility," "Refer to row," "Non-select brand category," you can use these options. So these are the table-specific properties which we have. There are generic properties which apply to each and every visual, like header icons. So header icons are these icons which you are seeing. Can disable these header icons, but they will not get disabled here; these icons will get disabled in Power BI service. So even if you disable here these header icons, you'll continue to see; they will get disabled once you publish the file. You can decide the color for these icons, border, etc. Now you can decide what icon you want, like visual information, visual warning, visual error, drill down, drop down, drill up. These are generic options. Right now you're not seeing all of these options; whatever is applicable for this visual at that particular moment you are seeing it, but again if you uncheck some of these options, like filter option, if I uncheck, you will see that still the filter option is there. Again, this will be hidden once we publish the file. You can use "Reset to default." This option is available at many places; helps you to get to reset to default. "Tool tip." Right now you're not able to see the tool tip; if you enable it, you will start seeing a tool tip here, and if you disable it, the tool tip would be completely off. "Alternate text while loading," what alternate text you wanted to show? You can also use FX option for that. "Advanced option" is basically responsiveness and maintain layer order, which is off right now. These are the properties used by table visual, and as you see we have done quite a lot around it. What we can do is some of these things we can say "Reset to default." So one of the property I've done is basically the grid; I have reset to default. Similarly, "Style preset," reset to default; title is fine; sizing and style is fine; reset to default; the text colors, column headers, reset to default; values, reset to default; specific column, reset to default. And as you now observe, we are almost at the very starting stage. Yes, I'm leaving ahead what I've have done as a background color and the headers, so I'm keeping them as is, but in this manner you can revert few of the things to reset to default. It helps you for experiment and come back to the initial position. So we have now learned how to create a table visual, to multiple sorting, and do various kind of formatting on table visual. Let's start creating a matrix visual. So I'll add another page for that using the plus button at the bottom, plus button. Let me double-click and rename "Matrix." You can also right-click and rename. If you want to delete, you can delete; duplicate, you can duplicate. If you want to hide, now when you hide it here, it doesn't mean that it's going to hide here; it's just going to show you uh that it will be hidden, but it will be hidden only in Power BI service, in the viewing mode. Now to add a matrix visual, again we can have option either for from build a visual which I enabled from here which was not visible, or you from the Home tab you have the insert option. The Matrix visual is lying here, if you can notice, and in case of the top it's lying here, one of the two places you can use. I'll click on the Matrix visual here on the build of visual pane and bring it little bit down and and make it little a little bit bigger. Now unlike table visual, we have some different options like row, columns, and values, and once we add that you will be able to understand what I'm talking about. And matrix visual has quite a lot of option for display also. So first we focus on the display related options, and then we go through the other properties of the Matrix visual. Um, quite a few properties of the Matrix visual is similar to table visual, but this one property which you will find missing here is basically sorting on multiple columns; that's not available here. The sorting automatically get adjusted when you have multiple rows either on the value or on the categories. So let me start creating a matrix visual, a very simple Matrix visual. I'll drag a brand; it will group the everything by brand, and then I'll bring in the major, the values. I can actually also bring a quantity column, and as you can see there's a sum of quantity, but if I try to remove the aggregation, I don't have any option. But if you go to a table visual and you try to add a quantity column, let's say inside a table visual as a column, you do have option of aggregation. "Don't summarize," it means you can group it by quantity, but the option is not available in Matrix values. The values has to be aggregated, so that is why there is no option for no aggregation here; don't aggregate is not an option. Let me cross that. Now you can add multiple majors if you like. I check that you have one row; you can have multiple rows. The moment you have the multiple rows, you will start seeing the plus button. Now it depends on you how you want to use that. The moment you have more than one, you start seeing the drill icons; you start seeing these buttons also. If you press a button, it will only explode that particular brand, and it will make it bold. And if you want to go up, you can close these buttons, or even in the open stage you can use this button which is known as drill up, the second button. And right now because it's only the row where we have the multiple columns, that's why you are seeing is later on we'll see that when columns have multiple, we can do the same stuff on the columns also. Now the second button is drill down. Now what does drill down button does is let's say right now if I click on the brand one, it doesn't do anything. The moment I press this, click on drill down, and now if I click here on the brand one, you can see the brand one is getting filtered. Let me use drill up and uncheck this option. The next one is "Next hierarchy level." What does it do? It doesn't drill down; it simply takes me to the next hierarchy levels, and as you can see the totals are same.
What we had previously, it means we are just seeing the next level come back to the top level. You can use drill up if there are more than one level. Same thing, you have to use multiple times, while the next level take us to the next level means it's take us to the next available level, which is basically, in this case, the next level is like this going down. The expand adds the next level. If I right now I have only one level, but if I have more than one level, I have to use expand multiple times. It starts showing both of them, and that's the place the new Option comes in. So now you have expanded it, the display is like this. This display is known as stepped layout. The options in The Matrix visual has changed. So once the metric visual will finish, I will showcase you the new options which has come very recently. You go on the visual format. Now I have already have a format pane open. If you don't have, again you can enable it. If it is visible here, you have an option here on the three dots for the format Pane, and again in the view tab you can enable it. If you scroll down inside the row headers, if you scroll down the options, you will see stepped layout. Now right now it is on. You can increase the indentation here. Okay. Now the second option or the layout which is, if you switch it off the stepped layout, if you switch it off, then it will give you this kind of look and feel. So this is non-stepped layout, and sometime we use this. Now there are plus and minus icons. You have option for that. One is definitely you can change the color. You can make them little bit bigger if they are looking small, and one more thing you can switch them off.
Now we had a pretty good Advantage when they have, we could have pressed this plus button and open it. Let's go up and see what happens. Now if I click here, I don't have button. I can't go there. I have to use the next level by either using the drill down or by expand. Now let's further play around with the Matrix visual. Before I go ahead and make it little bit complex by adding column, I would like to show you one property which actually will become little bit complex once I have the columns, and from using that only I would like to switch. How would we add columns to this Matrix visual? So let me remove even categories from here. Now if I go to the values, scroll down [Music], I have this option switch values on row group rather than columns. If you this is right now off, if you switch it on, you start seeing your measures on the row. Previously they were on the column here. Now I can completely remove any kind of row and column to have a KPI look. You've seen the row look, or I can only bring in data on columns to have Majors on the row and the data on columns. Again I can have multiple things on my column, and once I have more than one thing, I have options like drill down. If I click, I'll go there. Drill up, go to the next level. Drill up, expand. Both of them are available. In case of expand here in the column, we don't have a stepped layout. It's always going to be like that. So now you have seen rows separately, you have seen column separately, and you have seen Majors on the row. Time to bring Majors back on the column because we are going to create a pivot table kind of a structure by moving the brand here, and I'll tell you a new option to add the data. I'll click add data here, and now I'm not dragging it from the data pane. I'm simply going it and adding it from here only. So now we have a pivot structure where we have brands on the row and categories on the column, and the majors are also on the column, and you can play around. Take the measures on the row. I can further complicate it, and to do that complication let me bring in brand here, and let me drag categories little bit below, and knowingly I've taken brand and category columns here because they have lesser number of values. Number of headers are limited. Now I'll go and add state in the row and see also in the row.
Now you will notice a difference here. The difference is drill down now is asking where you want to drill down on columns or on rows. If I use column and I expand it, I'll see brand and category together. If I change it to rows and I expand it, now rows are expanded in this manner. I can create really complex structure using the Matrix visual. Let me add customer name to the rows, and if I now further expand it, has a pretty complex structure, but you can see there are too many totals out here. I don't want so many totals. How do we control the totals? You have multiple totals on the columns, multiple totals on the row. So what we are going to do here is now we go to the row subtotals. We can disable them. If we disable, everything is disabled including the grand total, and let me to check that out. Let's drill up little bit. Let's make our task easy. We don't have a grand total also. Let me enable it. We have a grand total now. What I'm going to do is I'm going to enable per row level, and it's all right. Now all are there. Now I can choose State. Further expand it. Now state is the first level. States control your grand total is the totals of state. That's the highest one, isn't it? After that, if your total is grand total, City controls the total which you look at the state level, and names customer names will show you the totals which you see at the city level. I can go ahead and decide which subtotal I want to see. So I can choose the row level. I say state. If I don't want to see grand total, I can off, and let's look at the impact by going up. You don't see it. That let me bend it. Now the city level is added, and I'll switch off the grand total at the city level. You don't see the state subtotals coming out here. Now it's only this one. There's no State subtotal. What happens if you drill up? We still see it, but when we expand it, we don't see the state subtotal. In this manner you can control. Not only you can control, let's say you want to have the subtotals, you can give the subtotal some name. I can call it, and where I want it, bottom or top. I don't have a control at the individual row level, but if I go to all, I do have a control. First what I want to call Total as, and I can use top. It means first the subtotals will come, and then the individual split will come. We can't change that at the individual level. If I expand further, I do get an option to control things at the name level or the customer name level. So this is the manner you control the row subtotals.
Now let's try to control the column subtotals. Little bit up the column, we right now have only two of them, and we can completely switch off the totals. You will get rid of all the totals here including the grand total. We may like to have grand total not others. So again we can switch it on. We say per column level. First of all let's look at the all level. What options we have. So at all level we have total. We can rename it. Uh, we have the values option, and if I go to the Brand level, I definitely will end up disabling the ground total which I don't want. I want go to the category level, and there I disable it. I can give a different name also if I want. So let me disable it. Now there is no sub totals. You will only see a grand total at the end. Values is disabled at the individual level. We have options for column grand total for colors and row ground totals for colors and font. Now quickly have a look at the properties of the Matrix which which we can use. So as usual the generic properties of the header icons whatever you want want to disable, and as I explained earlier these properties will apply to Power BI service than here, but just for an example let's change the color of the background so that you can see where it can be. Border color is white. I'll going to make it black. You see the Border also. Transparency, then icons, whatever icons we need. Again if I uncheck it, the impact would be there on service. Right now there's no tooltip. I can enable it. Tooltip is of default or report page. Right now report page is auto, means it's automatically creating that, but we can have a report page which we will learn later in the tooltip. You can control the text size, label color etc. as per need. Similarly the background color, if you would have remember we have set up this background color when we have done changes in theme. Alternative text and advanced options are very similar at the visual level. Let's look at all the options. Styles and size and style very similar to table visual. Padding again how how much padding we want. Background we would we can switch it off. We don't need a background. Visual border we don't need. Shadow we don't need. If you want we can have a shadow. Title we can add a title. We can added a title and then we can add either from here or on the top. We can call it as Matrix visual. Enter font color, background color, alignment, center alignment, a subtitle we would don't not like here. Divider I don't think we like here. Same as the table visual. Spacing again we can increase the spacing. Same as table visual. Style presets same as table visual. We can have different like bold header and all those, but I think I would like to stay with default. Again grid, horizontal grid, vertical grid, border and options whatever we want to change. Same as table visual. Values very similar because we have alternating colors. We have two options just like table visual to have multiple colors options. Switch values on row we have already experimented, but here how does it look like? You can see it looks altogether different now. Column header is something which is basically for the column headers, and to make it bold and italic to differentiate. You can see these things are getting chopped here. Then we can do the alignment. Right now I'm going to leave that options. Auto size width again whenever we do some kind of filtering we don't want to change it, and if you have specifically go ahead and done something you don't want it to change, switch it off so that it doesn't change when you do the filtering of data. Row headers these are our row headers. Again make them bold and italic so that we can see it. Now when you go up still they remain bold. When you go to the next level they are bold, and when you expand them they are still the bold because now we have forcefully made them bold. Plus icon we have removed it. Let's switch it on so that we get collapsible property. At the end options we have already used the step layout and non-step layout. Let's now switch on the step layout so you can see the difference again. Column subtotals and row subtotal we've experiment. Column grand total you can't control the grand total enabling disabling. You can only change the color and the font. R grand total again font and colors or background. No control on enable disable. Now specific column here what you will see is when we talk about specific column we are only talking about values. We are no more talking about row and columns unlike table visual where we talk about each and every column. When you talk about specific column you are only talking about net, but there are few additional options here. Header subtotals, totals and values means they can apply to subtotals and values. So you can change the properties like I can say apply to header, apply to total, and I just want to change one property which is basically alignment. Let's say for the net value and I want to make it right align. So you can observe that the net has been aligned right. Decimal place I can change the decimal place at visual level. Let me make it zero. So now n don't show any decimal place at the visual level. Same way display unit can be formatted at the visual level. I can show it in thousands, and when I show it in Thousand I may like to have decimal places. In this manner at the visual level I can control the display units. Next it's cell elements. It is forther conditional formatting, and one of the limitations of the conditional formatting which we have in the Matrix visual that it doesn't apply to rows and columns. We have an additional option here for data bar, and the data bar option actually is there on the table visual also, but it only come for the values. When we go ahead and explore the conditional formatting in details we will see this option also. Again URL icon we need to have some data URL to use this, and if the URL has been used in column headers or rows then also we can have an icon for that. Again image size we once we add some images we will be able to see this. For that we will need image URL. So these are the various properties in The Matrix Visual, and one of the most powerful display which is available with us is Matrix visual. While it doesn't have the double sorting, but when you sort on now this is one question which is basically on the sorting, and this is little topic which typically misunderstood by many. So when you do the Sorting on state, it will automatically sort the category and subcategory in the same order, but you can go ahead and sort it on City, and then based on the city sorting automatically the state sorting would happen, but when you sort it by net, which net it is sorting? It's the column ground total because we have used the column, so it will going to sort on the column ground total, but if you don't have the columns definitely it would be that particular column sorting. So if I go to the visual level and remove my columns and now if I'm doing the net sorting, it is actually sorting on net. I can go ahead and sort on margin and cross, but if I have columns they are sorting on the ground total of the column. So let me bring only category so that you can see see that grand totals. You can go and sort the grand totals. You can either sort on the columns which are there on the rows or you can sort it on the ground totals of the values, and then you have the sort ascending and descending option which you can use. Same options in the three dots as other visual. Export, show data as table, remove Spotlight. This is Matrix visual for you. Power BI is ever changing, and every month it keeps on giving you new and new features, and same thing has happened before I could have released the video or the series. We got few new features. Some of them are already covered as part of this video or the series, and I would like to Showcase you couple of features which has been added into the Matrix visual. So let me go back to the file where we have the Matrix Visual, and this was The Matrix visual we have created in the past. Let me open the properties of this Matrix visual. I have already clicked on the right hand side format, and because of that the format pan is already open, and I already have the properties open. In the properties under the layout and style preset, now we got few more layout. The layout which we used to know as stepped layout is now become your compact layout. So if you see right now it is the compact layout, and I can extend it further, and you can see the values are stepped out, and there you have the indentation which has been given. So basically in the compact layout you have indentation. Using that indentation you can move around the things little bit, and this is the format what we use to call as stepped layout. Other than that also couple of formats have been added. So first format which is outline format. If you look at the outline format, and there you have this like a format which is stepped layout off, and the total is above. You see the state total. The total is here at this place, and then you have these detail level data. Totals first the subtotals, and then we have the data. Now in this layout you have an additional option that is repeat rows, and this was the one of the feature which you are asking for long. We want these values to repeat like a table visual. We don't want them like a pivot table where the values are non-repeating. We want the repeating values, and here the values are repeating as you can scroll down and see all the values are repeating. Now totals on the top and values are repeating. Now let's go ahead and change the format to next format which is tabular. In the tabular format you have have the same option repeat row headers which is right now on, and you are seeing that the headers are repeating, and the totals have actually moved down. If you scroll down wherever something is ending then you get the totals, and here in the total also the names are repeating. Now if you want to close that repetition, repeat row header you can switch it off. Once you switch it off it is very similar layout which we used to get in tabbed layout off. So now these are the couple of layouts which has been added. One is very similar similar to the old one which is compact layout which is very similar to the step layout and non-step layout. We got tabular format as well as the outline format. Now the changes did not stop here. We got something known as blank rows. What happens? Let's look at this data. Now let me go one step up here so that you can easily understand that, and let me click on add blank row. After these subtotals you got a break. You got a blank row, and this is something you were asking for long that you know give us some place where we have this break, where we have some separation between the parent and child. There should be some empty rows which we wanted to insert, and that the same feature has been given. Now there is a color which you can also apply here. So use the color on that particular row so that you can enhance the visibility of your visual. So now this visual will give you a different look because you have a color. Now in the color you can also use transparency. You want it a little bit transparent, so increase the transparency. Then there is an option for Border also here. So click and then you will get a border. Now you have a border position like top, then you have bottom, only at the top, only at the bottom, or you have top and bottom both. So right now it is like to both top and bottom, so we parallel lines. Then the color definitely you want to have the color to that, so you that color of the Border. Then transparency of the Border can also be there. Next is width. In case you want to have little bit wider width you can use that. In that manner you will have different kind of visual experience. Now you can see this visual. The same Matrix visual is now looking a little bit different, and this is because of these new changes which has been provided to us which is giving us much better look and feel, and right now Power BI is fusing a lot on providing you such a new feature your visual experience. So these are couple of features which has been added in Matrix visual very recently. Enhance your visual experience. The visual we want to learn now is the bar visual. So let me add another page by using the new page button at the bottom, and I will use the bar. The bar visual is actually known as clustered column bar or clustered bar chart. Both are available in the build a visual and in the Home tab in the insert option. So let me start with the clustered bar chart which is also known as horizontal bar chart. Let me start that. Now the options you have here, and some of you might be surprised why I'm not getting a add button here, because after the December customization I've choose for build a visual, and because of that the on object interaction option of having the columns here has shifted to this place which is more classic look, but I like that more, so I have opted for that. Now let's skip the y axis now and
In the Y axis, as I can add the data directly, I will go ahead and add item brand now. Now, second is X-axis where I will go ahead and add a measure. Now, here in case of the clustered bar chart, the Y axis is basically a categorical axis and X axis is basically a numerical axis. So here we are getting the values on X-axis, which is this, and we are getting the categorical values here on the Y axis. It can use continuous values; we will see an example when we put across a date column, then it can use continuous values.
Now let me duplicate this, and I'll also tell you how you can change a chart type. So when you click on this, now what you can do is you can go to Builder visuals and you can click on cluster column chart, which is not selected right now, and it will become a cluster column bar. Now in cluster column bar, the X-axis is brand because you are seeing the brand on the horizontal axis, and you are seeing the numbers on Y axis.
Now let's further explore it; what else we can do. Now before I go to the properties, let me tell you a few things about this visual. So we can have more than one axis; similarly, we can also have legends, and we can also use small multiples and tool tip on this. Now tool tip, you can add additional column; by default, you can see the tool tip is on. I can click on the format and start seeing that.
Now before I change any properties, let me show you one thing which is column, and under the column you see the color, and in the color this FX option is there, which means conditional formatting is available, and you have to keep noting that down for what all cases the conditional formatting is available or not. Let me bring in one additional measure here, which is other than net; I'm also taking in gross. As you can see inside the color, now there is no conditional formatting option which is available in the columns. We have each series, and for each series you can give color, but we don't have any option for conditional formatting, like if I go for net, I don't have FX option. Now same way here you can see the conditional formatting option, but if I add a measure, I don't see a conditional formatting option also here. So conditional formatting only along with one measure.
Now let me remove the measure, or even without removing the measure, let me see can I put a legend. So I expand the item and from there I try to drag Legend category as a legend. I'm not able to do so with two measures. You can't have Legend. So let me remove the gross and let me now drag category, so I can have the legend with one single measure only. So if you have only one measure, then only you can use legend. You cannot have both couple of measures and legend in the standard bar visuals. It is applicable for both bar and column bar. Again, you can see that I am not able to see the FX option. If I go to category one, you will be able to see that I'm not getting an option for conditional formatting.
Now instead of bringing this category onto the legend, I can also bring this category on the X-axis. When you bring this on X-axis, as you can see it is broken down by brand and then by categories. This option where it starts breaking down and you can individually work with each bar, we need a little bit bigger visual for that. So let me adjust these two visuals to have more space. Now you can see brand a little bit better. So brand category and Brand C we have, and this is coming because of one of the properties, and for that it's already showing exclamation signs that you have to reduce the font. So if I reduce the font of X axis, I can get the better data here. Now you see this is concatenated label off. So by default is this concatenated label off, but if you switch it on, you will see that the brand and the category are concatenated together. So if you want them to concatenate together, then you need that option. You can off for concatenated label off; that's a better option. Here you can see this is the default ordering which we have, brand one and then categories are ordered. Now this will work only when you have sorted it on axis brand and category. If you sort it on net, this is not going to work out in the same manner. Okay, so now you can see the brands have started repeating. So this from the three dots, always use brand and access and concatenated label off if you need that. Now this option was previously not available here, but now this option is also available here, and I can go here and pull in category, and why I'm not seeing it, let me expand it, and you can see the same option concatenated label off is available here. But as you can see, the data is pretty small; it's not visible. Now labels which are we are getting on the Y axis right now, there is no option here to other than reducing the font size. I can do making them horizontal, and again it is, you know, showing me the message that it is too bigger in the size, not able to display the complete value.
Now let's focus on one of these charts for other properties. Now when we learn the conditional formatting in some time, what we're going to do is we are going to give one single color for a brand, or if you have a category below, we will try to give one single color for the category, and you can have multiple categories; means you can have multiple levels also, and it is not that uh you have to show all these levels in one go, just like we have shown with the concatenated level off, you can do the same way drill up, you can do and then you can say, okay, expand, or you can also use the drill down option. You can enable and you brand 10 and you drill down with the filter of brand T. Now you might have feel that the other visual is also getting filtered, and this happens because of interaction between the visual. Every visual interacts with another visual unless we stop it, so we will learn that a little bit later. Now this is our visual, and in this visual we can either expand and have the labels together, or we can have one level and then we can go to the next level. Same way as Matrix, we can go simply to the next level, come back up, we can expand, have them together, or we can use the drill down functionality. When we click on the bar, it goes to the next level.
Now let's look at the properties, size and style properties. Under the size position we know because of the size it is coming, height and width, then from where we are starting. Lock aspect ratio; if I lock it, if I change the size, then it will keep the aspect ratio. See, I'm whatever I'm trying, it is keeping the aspect ratio. Now padding, uh padding is basically the outside. Right now I think one of the side it is zero, so that's why there is no padding coming in, but we can change it like, see net is just now look at where the net is. Okay, so 6 pixel, 10, 5 pixel, 2 pixel, the differences. Similarly, the right hand bar, if I give the right hand side padding, so how much padding is going to be, how much padding on the top, so we almost end up utilizing. Background is the background color, so you can have some color if you want on the background, and then you have to reduce the transparency to see that color. Visual borders, again same as table, we are not going to experiment with this. Shadow, same as a matrix and table, we are not going to experiment it. Title, we have already explored, and by default it gives a title and um then FX means we can give a measure in the title, which we will learn a little bit later. We can make the title center, and then also inside the we have subtitles. If you want to give it, again subtitles, you have the FX option, means you can use the measure there. Divider, uh between the title, subtitle and the rest of the area, you can use divider.
Now X-axis, we have experimented in the title. There is something which you might like to use; you might want to switch off the title. So if in X axis if you see, now there's no brand written here. Now let me go ahead and switch it on, on, and you will notice now there is a brand written. If you switch off the title again, you can play around with the properties of this one and the color. Now the color of this one is how is it going to change? Is it going to change on the grand total value or is it on the brand value? Each brand value that we will experiment and see usually it only checks the grand total value. Again, FX color means I can use a conditional formatting measure for that. Once we learn that, we will try to use that. Now we'll go to the layout. Now minimum category width, you can play around, and as you can see, the moment I increase the minimum category width, the bars are little bit wider. Now we can go to the Y-axis, and in the Y-axis you have this option of minimum and maximum, so you can change the range, and you can also use measures here, means I can have a measure which will decide my, you know, min and max. So right now you it is automatically deciding; it's starting from zero and and it is going to 1 million. So basically the range is in millions, okay, but you can decide from where it should start and where it should end. You can devise some kind of measures, and the tip is when you create such measure, find out the minimum value of for the brand whatever you are using here, take just some 10% less than that, and same for the high value, 5% 10% above the value here, less than the value and here above than the value. Now sometime what happens, you have values which are pretty small compared to other values which are pretty large, so you may want to use logarithmic axis. So as you can see these numbers now, see almost same. This actually helps when you know one value is pretty large and another one is pretty small. You can use logic scale. Invert range, again you want to move that on the top. The now we have the smaller value on the top and the larger value below, so smaller to bigger on the invert side. Now comes the values. For the values you can see the Y-axis values are switch on and switch off. Pay attention; you can use FX, means you can use conditional formatting, uh display, auto. Right now I can use none, no formatting. Now you can see the absolute value. You can say auto, it means it will follow the automatically what it gets best, million forcefully million, thousand forcefully thousand. I leave it to none, or I can even leave it to auto, let it decide. Usually it is better to keep auto. Which axis position? Now Y axis can come on the secondary Y-axis side or on the what you call as right hand side. Title. Now you want to give a title to the Y axis. Now right now the title is net. Let's give something else, net net value. So now we have title as net value. Again, you can use the color using conditional formatting, uh show style, show units only, show title only, show both. So units is in millions, show both, so we can say net value is in millions, and that is much better option if you wanted to try out because what happens in case you are using this auto, it is always good that it shows you, you know, if it is showing the values in K and millions, that's a good idea to have.
Now legends are off right now, but when we use legends we can play around with small multiple. Again, when we use small multiple we'll use. Now grid lines is something it is showing that you know we have the horizontal grid line, but because of the color you might not be able to see. So let me make make it a little bit darker. Now you can see the horizontal grid. Now they are dotted; you can make them solid or you can make them dashed, what you want. Width, you can increase or decrease depending on the require. So this is, you know, a horizontal grid. Now zoom slider is something uh which is really important, especially when you have large number of rows or huge data, then it will help. Now let's invert the axis before we understand that. So both we brought on the same place; it's not that it's not going to work with that, but by we usually have a habit of seeing the things in a particular manner, and it is helpful in that. So on the Y axis as you can see there is a scrawler, and if I bring it down it is bringing in the value. So especially if you have huge number of data points and some of the data points you are not able to see the values, this can help. Now slider can have a label, slider label. So once you on the slider label, you have a label on this side. So one is fixed label and one is changing label. Now the one label is changing and one is fixed, so that is the advantage. Slider tool tip, so once you scroll down, now it will have a tool tip also how it is moving down. So these are few things you can play around with the slider. Again, it depends on what kind of use case you have.
Now columns, we are seeing multiple categories, but instead of color, still we are able to see FX. Now always, instead of having legend, always try to have the axis, multiple axes. Now you will ask, now even if if I expand, I I see all of them in the same color, isn't it? When I expand, you see all the categories or brand in the same color, but when I was using legend, they come in multiple color. So if this category is in the legend, you will see them into multiple colors. So I can have color for category one, category two, category three, but I can't you switch this color with my own choice of color manually. I can switch, but I can't keep it controlled; means the moment you doing some kind of filtering or there are additional values, this category one may get a different color or category two may get a different color, or based on the other operation it may change. But if you keep it here, because this conditional formatting is enabled, and also you can see it is little bit better where it occupies the space, and we will be able to use conditional formatting to color that. So once we learn the conditional formatting, we'll color them in different one, and you'll find this is a better option than using legend. Wherever you can avoid the legend, so use multiple axis, expanded, concatenate label off, whenever you can avoid the legend, we will understand that a little bit more. Border, as you can see the borders, if you have have the border for the I change the border color a little bit so that we understand where the color coming in. So you can see the bars of borders, and you can have transparency for the borders. There are few features which has been very recently added, and one of the feature is basically this transparency, so and I waited for the border to come because when I make this transparency is 100%, you can see that there is nothing visible, and now if I go ahead and check this match the column color, it gives the matching color. Okay, the color was actually green; it gives me matching color, but that is actually transparent, and what I can do is I can make it also 100% transparent. So right now there are bars, but they are not visible. See, I can see the tool tip because of the bar, but I don't see. Now because of that there are multiple things you can create. So moment I think I use the transparency a little bit, I will be able to see the bar. Similarly for this one, I can use a little bit of transparency to give that transparency kind of effect. Now the inner bar is little bit transparent, and the border is border is not at all transparent, gives a different kind of look. Now both are completely not transparent; they look into the this one. So these kind of combinations of having the transparency and having this border match color or border of its own color can give you this combination. You can hide it, so purpose of transparency we can decide based on the what we are going to do, but anyway the transparency if you look at it and but let's do one thing, let's call it as uh bar one. Let's duplicate this page, right click and duplicate, because this is a newly released features and let's have a look at it. So now you can able to see in a much better manner how does uh this behave. So this transparency and border um you can see the advantage of those things here.
Now similarly you have the layout. Now in the layout when you went here, the reverse order, sort by value and spacing between the category. Now spacing between the categories is something if you increase that, as you can see is increasing, and so max width has one play with us. Max width was there uh which was actually allowing you to do something. Now again this is the second one where space between the categories is allowing you, you know, have smaller bars. Now this reverse order and sort by value is something which is not applicable on this. This is actually for stagged bar chart, and this is really good property. When I come to the stagged bar chart, I'll explain you. So let me increase a little bit width because that's too small, and also I'm going to make this border as none because I want the bar to take the width, but I'm telling you with bother it was looking much better. I can make it as a one pixel. Okay. Now let's come down. Now data label, again something got added in December. Data label is there for a few months now, but in December we have some enhancement inside the data label. So first of all the position is horizontal; I can make it vertical. So now this is one thing. Overflow text, I allow it, means if even if there is a chances we need to overflow the text, means overflow of text means if it is not sufficiently coming, let's say if I do the position as right. Now the position is auto. I say inside, and now bar is very small. See this bar is very small, then it is overflow. Now if I switch off the overflow, if I highlight here, you can see the values are not appearing here because right now what I have done here is I have switch off the overflow text, but if I enable this overflow text, you will be able to see this value. So this is the advantage of overflow, but keep it auto that it takes some place. Right now it is outside, but if you want there are need like I really want it outside only. And optimize label display is another thing where you know you can have if you check that you have the maximum width which you wanted to give, you can control that. Now new thing which is now inside the data label which allows me to now show the title. Now what is this title? The title is basically the net, and where the title should come, same as series name or custom. I want to give some other title, then I can add a title, and you by adding this title maybe I want to add the category as a title. Let me drag the category as a title, showing first category. Let me do one thing, let me go ahead go to X-axis and completely disable X. Okay. Now I have a category and value, and you will say this is looking too busy, and let me only make it as a category visual. So now what's happening, there's a category and there's a value. So now let's go to the position; we can see now. So now we only I removed the brand. Now only we have a category and the value, first category. Now first category or last category doesn't matter because because of the row context going to come that we have transparencies, means we can make it little bit transparent. We have the color; we can choose a color, means I can have a different color for the category and the different this one. So now what is happening, there is nothing written here on the X-axis; everything is written there. And now position is something which we can decide where you know the opt we can say okay, inside and or we can say inside base. Now everything is written here, inside base, and because I have
Chosen a color, black; that's why it is coming so. Now we are getting the title along with this one. Furthermore, when you go down, this is the actual value, the net value, which is getting displayed in the label. What all I wanted to play around with that.
And if I go down here, we have the display unit, which I can control. I can say none, so it starts showing the value. Now I even don't need the y-axis, actually. Now I can go ahead and completely switch off my axis because I have the values. Display unit, decimal place, Auto, Show blank as zero, or show blank as hyphen. Like if there is a blank value, I can say here, show as hyphen, which is previously not possible. Now these are the enhancements which have come recently, and some of them came as recent as December.
Now, detail label is something which came very recently in December 2023. Now I can add one more label. So I'm already using category and net with that, and let me bring in Gross value also here in this one. So now I'm seeing gross along with that, and then I can decide the font. I can decide the color. You say, okay, let's differentiate it with a different, little bit different color. Maybe this is my gross. Transparency and formatting is none. Decimal place, Auto. We want to give a background to this; switch on the background, and then we can decide what one wants the color and what is the transparency we want.
Let's go to the layout: multi-line, single line. When I go to the single line, what I can do here is, let I don't want details to be there; let me switch off the detail. Now look, it's looking much cleaner. An approach to have this and, and definitely we can play around with the colors. So now what is happening? This is something you would have wanted in the past, that you have the categories and their label, and I'm going to convert this into all to a different visual.
Now let me go up, and we, we, we were playing around with the colors if you remember. Let me create the transparency. Now this is only inside the box. Me switch off the borders; I'm only displaying the values. Let me bring in the brand back. Brand is low. Okay. Now here in the label, we can't direct two; we can't direct to; otherwise we could have done the brand, but in this case, now what we can have here is we can go ahead and enable our values. So I have done a few adjustments, and you can see the values.
Now you may like to have, you, you know, both brand and category. Then how would you get that brand and category values? You might have that question in your mind, like, you know, when I'm adding this U title giving me first category. I'll tell you a very simple major. So I'll go to the item Dimension; I click on it, and I create a major, and this major is going to work when you have both of them together. Okay, so we'll call it brand at label, and this is nothing but Max of item brand. If you remember, we were taking first category, item brand, then we say m per to give us space, m% space, m per Max of item category. What would happen because item and category are already in the AIS? Actually, we don't want to display them, and I, let me give additional space also here, and maybe I can give a hyphen because I know I'm going to display the value. Now I can, instead of this one, I can bring in this one. What kind of label I created? Brand category label, Max of item brand and Max of item category. You will see how will it work. See item when the brand one is in the my context, brand one can only be the maximum value, and category one is in this row context, so category one can also be the maximum value. In this manner, you can get these values, and now you can play around all these values and everything. Now it can create altogether a different kind of visual where you are only displaying the visuals like values like this.
So these are all the experiments which you can do, or I can reduce the little bit of transparency to see these values, and I can play around with so lot of combinations are possible just because of this properties of transparency and the data label customization which has been enhanced over last few months. So you have a lot of flexibility, how you want to display your bar visual, stagged visual, wherever this is applicable. Now plot and area background, if you want an image in the background, then you can use it. Then again you can decide the image fit and transparency. Reference line is something really important. Now what happens sometime is basically you want to plot a reference line, basically a line which is going to give you a reference. So I can add a line. Now it asks me to choose a line. So right now I would, I can choose a constant line, or I can simply choose an average line. So I prefer to choose an average line, as you can see this is my average across all the values based on what net, because right now I'm only using, using net. Now the line properties, you can change color. Let me make it black, and transparency is transparency 0%, so that is visible. Instead of Dash, let me make it solid. Position in front or behind. Sometime you want it behind so that it does not cross the bar from the top. Now focus on this location; you are able to see that white color iPhone above it. Now I'll go and move it in front, and now you will observe that that when it is in front, you will not be able to see that quite complete.
What I have done is I have reset my data labels to default by using the default, reset to default, and now so that I can show you the reference line, and uh, because there are too many overlapping labels, it was not able to show, and the one thing which I enabled is now I've enabled the data label. Now it is showing, where should I show, left or right? I can decide the position, whether I should show it here or here. I can decide the position above or below, under or below. Again, positioning a style, name or both, data value, name or both. I, both, average line value, display unit, I can set to none and decimal places Auto. Before I take the next step, let me do one thing. Let me uh remove some of the features which are not required right now. Let me rename this page to Bar two. Let me now explore error bars. Now error bar is on the series is net right now. Error bar enabled by field or by percentage. So I used by percentage, and upper and lower bound I can set. Now bars on or off, I can use, but definitely I want the bars. I can set the bar color. I can increase the width a little bit. Uh, marker shape, I can decide, marker size, size I can decide, border and color I can decide. Error labels, if I want, I can enable the error labels, so it will show me how much error label it is. Label from absolute or relative numeric position or relative percentage. Relative numeric we can do, or we can try relative percentage, and then finally we have a tool tip right now which is on the tool tip here. What we are talking about is the error bar tool tip. If you switch it off, it will not show the error bar information, but this is not the overall tool tip. So basically, if you go here, now it is showing the error bar upper and lower bound. If you switch it off, it will not show it, but this is only related to the error bar; the it is not the overall tool tip. The overall tool tip is available under the property pin. Now I'll switch off the error bars. So now we are done with our properties. Now we can go to the generic properties, header icon, same as other visuals, tool tip. We right now able to see the tool tip; we can switch it off; there would be no tool tip, alternative text and alternative options, responsive, and there is so much you have for the clustered bar, and same can also be applied for the bar visual. There are multiple options possible to display this chart using, you know, xais, y AIS, Legends, a small multiple. You can also add additional item on the tool tip if you want. Let's say I want to add gross; I want to add discount for that; the tool tip needs to be enabled. So if the tool tip is off, you will not be able to see, but once you enable it, you will be able to see the tool tip.
Now the next thing what we wanted to do is we would like to explore a few more visuals, and then we would like to come back to the small multiple. So let's try to create a stagged bar visual. Now for that, again I'm adding a new page. Let me call it as stagged. We have two kinds of stagged bar visual: one is known as stag bar chart, second one is known as stack column chart. I'll start with the stack column chart, and then later on I'll show you by changing it to the bar chart. Properties would always remain same. Now the stagged bar chart, the it will become a stagged only when you use the legend. Before using Legend, it is going to be acting as a single bar. Now once we use the legend, uh, there is no option for having conditional formatting, um, so as of now, when I'm recording this video, there's no option of doing a conditional formatting and forcing is even by using alter rate. Now in few visuals we will see, once we deep dive into the conditional formatting, we will see that there are alternatives where we can get a little bit of conditional formatting in some visual, but this visual is where we will not get it. Means you can manually change the bar color, but not conditionally. Me, you can't have a major which can change your color based on, let's say, this category should look always red, so that kind of stuff you'll not be able to do. So let's start with it, and there are a few new features which came in December 2023, and we'll expl explore that, and they are the features you were looking for it, and I'll tell you the advantage of some of those. So we'll start with brand, which is on, we are going to put on the x-axis, and then we can have the y-axis where we can have value, and I'm going to take net for that, and then we can have the category on the legend. This constitutes our te chart. Now while rest of the property like size, title, xxs will remain same, and this concatenate label we have seen in the bar visual how to use it. Means uh, when you have more than one thing on x-axis, you can use it. Title, layout, Y axis, all these properties are going to remain same. You have the values of display title. Legends is compulsory for you now because we, the Legends are compulsory in this one. So let's understand the legend positioning. So right now there are legends are on the top left here. This position we are having here, we can say it is top Center. They have changed the position to the center, top Center position. Now we can move it around with, let's say, top right, and the one which I wanted to show is center right comes here. Now depending on the need, we can place it, but I think as of now, either bottom center or top Center is a better choice for us because we have seven, eight values, and we would like the width to be given. Now small multiples is something which we are going to play around a little bit later. Grid lines, if you want to show the grid lines, you can have the grid lines on. Uh, right now I can, the only thing I can do is I can increase the grid Lines by a little bit width, and I can give them different color so it's visible. So I can have the grid lines. A zoom slider, I already explained you, if you enable it, you will be able to zoom on the excess. So what I want to play around is in the columns, and in the columns as usual the series is has to be um as because it's um stacked bar chart using Legend. So individually you can change the color of the series. There is no FX button right now you can use, but there are a few new features came in here also. Now one is transparency; I can increase the transparency here. Now I can have a border; I, I kept, I'll keep really thin border here, match the color I'll use here. Uh, transparency of the Border I'll not keep very high; let, let it be there, and width I would like to keep a little bit finer width only. Let me have two pixels so that you can observe it. Now before I explain you this reverse order and sort by, I'll tell you what was the disadvantage previously what we have and what it actually addressed here. Before that, let me show you spacing between the categories. So as you can see the width of the bar is getting changed when I'm doing that, and the spacing between the series. Now, now this is something really important; it only happened between the Legends. So as you can see, the moment I'm increasing, it is changing the width between the serieses. So right now it is 3 pixel Max; I can have 5 pixel, and then series explosion. Note down what is happening right now. Look at the chart; this is my area, and what happens, it actually removes your y-axis and allows it to go beyond the values what it had. Now if you do such kind of stuff, definitely the labels is only going to be the saor, and yes, Power BI has enounced the label also again in December. We, the labels have been in us, but right now what I'm going to do is I'm going to decrease the space between the series; I'll keep it minimal; I'll also remove the series explosion. Now let me explain you what this reverse order and sort by order. Let's first understand what kind of sorting we have in the dots, three dots. So I made the adj just little chart. So if you go on the sort AIS, you can either sort on brand on N; it's already sorted on net. I can maximum do is s on brand. Now I sorted it on brand, and then internally it is sorted on category, but what you are asking for long is this sorting; you also want it based on the values. So this is the Sorting option you have. Now they are sorted on values; you can see this is smaller, this is bigger, this is smaller, this is, this is smaller, bigger, bigger, bigger. Now if I say reverse order, the bigger would be down and the smaller would be up. I'll further go down, and what I'll do is I'll go and say sort XIs on net. So now this is what you always wanted from Power BI, and now after December 2023, it has been enabled. The value, this value is the greatest value, largest value. So this is the largest value, and the values are again s descending inside the stagged bar visual. Data label again going to play a role because data label we have seen in the bar how new enhancement is going to help us out, but the moment I enabled, you get this one part of it. Now horizontal or vertical, I'll can make it vertical here. Overflow text, I can allow so that I can have more. I can add the title, so I'll add the categories here, and overflow text is helping me out here. I can have series name or custom. If I want to have a label, let me keep it as series name. Now next is value which I would like to keep net, though I have an option to change that also. I can go and make a gross value to appear here, but I don't want that, isn't it? Or let me show you some percentage value. Let's say margin percentage; I'm showing a margin percentage here, and the formatting is going to play the role. So I'm not going to say none so that I see the correct value. Okay, because otherwise it will take the format of the original major. So let me go back to the net value, and I'll say Auto format, because otherwise the too much data here. Now decimal place is Auto. Now details is something where I can add, and this would be especially helpful for those of you want to like to show the percentage of subtotal here. Now right now you don't know how to create that percentage of subtotal or percentage of total. I'm going to give you a major, and and we're going to achieve that because the moment I enable it, it allows me to have that gross, and I can see that another measure, but I, I don't need that measure; I actually want the percentage of sub total. Now percentage of subtotal is something which I have not taught you till now, but what I'm going to do is I'm going to give you a quick major here, and I'll tell you how to create that major later. So let me click on the majors which is Drive majors, and on that top of that I'll click measure and create a measure here which is percent of brand. What is my percentage of brand is divide net, and when I want to divide the net, I want to calculate the net again, and this I'm going to explain you later when we will show you how to create the measure. I want to calculate the net again, but this time when I'm calculating the net, I don't want to consider the filter of category; I want to consider the filter of brand, but I don't want to consider. So there is something known as remove filters item category. I'm saying the remove the filter of the category. So what would happen, while the net is for that brand category, the denominator would not have the category filter. Now this is a percentage column, so I have to mark it as a percentage also. Now I got a measure which is percentage of brand, and let me place that, and I have to go ahead and change its data type as none, and as you can see this is 78%, this is 16%. Now font is something which we have to really play around, so and it's not only the one font which I have to do; I, I'll make it smaller for all of them. Let me make it smaller for title also. So now you can see uh that uh we have all these, and now you have the transparency and all those, play around with everything. Show blank value as Hyun, then colors of each of these you can control. If you want a background, you will have a background also, and background transparency you can decide how much transp you want, but the moment you put background it because it takes additional space, so some of the values may go away, and definitely you need to make sure that um overflow is there so that whatever maximum it can accumulate, it can accumulate, and now I can make it horizontal also. Sometime it may actually look, now depend, if I don't want to use title, series name may be horizontal looks much better. So I think in this case, if I don't want to have those titles, and definitely because category I already have a label, I know which category it is. So in this manner I can have it. Now the next thing which is which I go down here, the layout which is multi-line, I can have a single line. Now I'll tell you where you need single line. So let me duplicate this page and tell you where you'll need it. So let me duplicate, and let me call it tagged one, and let me click on the visual and make it tagged bar. Now here if I go, I go down to the labels, and this is the place where I need it as single line instead of multi-line. I'll make it a single line. There is definitely, there's a difference which is very less which you can adjust by giving different colors or making it bold or italic, so it shows the differentiation between them, but this is something. So the sorting and the absolute value as well as the percentage value is something which was missing altoe and which has been enabled in the latest version of Power BI which is December 2023 on which I'm recording, and now you can see how much difference it creates. Now this visual is looking altogether different visual, and those of you who has watched my video on stagged bar in the past, in the beginner series, those of you who has watched it in the last here's full video, go ahead and compare that how much differentiation it is created. So these are the properties of the stagged bar which we have played around. So I'm coming back to the first one again; let me click on it and let's see if we
Want to explore some other properties also, so total labels is something again we want to switch it on. Now total label is basically the total, which is and now we have two more kind of stacked bar, which is 100% in the 100%. It doesn't matter, okay. The total only matters in this one because how much is this total and how much I'm percentage. So 1.1 million is my total, and of that 1.1 million, I am around 68 million, which is around 62 percentage.
And then again, there are few properties like you would like to have, you know, color or a background. I switched on the background, then you can have a background color and transparency. Right now it is auto display; you can say none if you want to show the complete value or thousands and split positive and negative. This one more option has been given here, so these are various formatting options which can make it, U you know, really look amazing.
And then we have the if want image, then we can have plot background area, and again you can add reference lines plus button reference line. The only reference line option we have in the stack bar is a constant line, so you can add a constant line. You can give a value. Now, based on the fil filtering, the value will change, so better you use this FX button and give a major, but right now just for our understanding purpose, I will give it let's say 500,000. I got a line at 500,000, and I can give a color and all those, so various reference lines are available, and we can use those.
Now, depending on the visual, these reference line keep on changing. Those who are on the last year's version, those who have not opted for these new changes, there used to be a separate section analytical pain, and inside that these options would be there. Now these has been merged; analytical pain options have been merged inside the visual properties only. And then you have the generic properties as usual; they are there as there are no differences. I would just leave them as is. Uh, there is nothing specific with the visual other than, you know, you can switch in on or switch off the tool tipe, but a beautiful tagged chart Visual and even the cluster bar visual can be created ated with the latest version of powerbi. You have learned about this stagged bar Visual and it's 100% stagged bar visual.
There is one more way these bar visuals can be created, so let me tell you. So what we can do is basically let's start with a that column bar. Let me bring in brand here on the x-axis. Now what I can do here is and what I said that you know staged is not an staged unless you use Legend, but there is another possibility, and what that possibility is I can bring in net as one of the major and I can bring in margin. So what is my net and margin is my gross. So this is basically my gross, and in this manner also I can create a tagged bar visual. Now definitely I can enable the data label where I can get the values, and now if you have your margin percentage and uh the net percentage, that could be another way to add few more labels here, but a stagged bar visual can be created on two majors also.
So if you don't want to use Legend, then you can create it on multiple measures. So either you can have multiple measures or you can have Legend. The thing to remember here also is when you use multiple measure also there is no conditional formatting possible. So in case of staged, you will not be able to do the conditional formatting. Now one more thing which we can do here is if you want to make it 100% tagged column chart, you go here, and it will start showing you the percentage. So these are actually the percentage how much of the gross the net is and how much the margin is. So so how much percentage the margin is out of my gross and how much is net. So there are two options you can create a stack B visual. One is using the legend and one is using multiple measur. Now I can have more than one measure also, so I can actually can bring in cogs. When I bring in cogs basically net doesn't have a value in that case I should have cost discount and margin, maybe these three will contribute to that. In this manner I can bring in my 100% column stagged bar visual or tagged column bar visual or tagged bar visual or 100% stagged bar Vis do. So in this manner I can have multiple such combinations with more than one major also.
We would also like to explore the 100% staged bar visual, so let me add a new page and let me say 100p tag. Now again there would be two versions: one is basically the 100% stack bar chart and 100% stack column chart bar as well as column. Let me use the column, and on the x-axis my favorite brand, on the y axis net, and definitely no stack is completed without a legend. Need to add a legend, and let me add as category. Now rest of the things are same, but let's just quickly have a look at xaxis: do we have something additional? No. Y axis: do we have something additional? No. Legend as usual, the positions uh small multiples we are not exploring right now. Grid lines column let's comes to the column, and in the column we have all the serieses where we can choose the color border. If you want to switch in on the borders, then we have the layout, and again this layout would be more suitable. We want it to have s by values and reverse order. We want the highest value at the bottom and the lowest value at the top. Space between the categories uh and space between the series is something we are more interested in. It looks much more flexible and maybe a little bit of transparency in the color. Let's go down to the data label again. Let's see what all we have now. So first thing is series uh horizontal or vertical. Here we can have it vertical uh position is auto. I prefer that. Overflow text let's allow it, so we can have I think horizontal would be better here, isn't it? We could get a value. I was more worried about this value which will go away in the vertical. Horizontal is much better option here. I want to add a title, and I while I can showcase you what happens when I add the title, but this something I'm not interested in as long as I have the legend label, but yeah value. Now here it is always already a percentage, so I can add the net. Now once I add the net, it is something which is uh not looking great, so let me go ahead and choose something here. I remove the decimal places and let me make it a little bit smaller, so now I can see the net value here. So net value and how much percentage it is and what is happening here seems like detail and this value are changing automatically along together; they should have been separate, but seems like some issue, and I can make it tyun when it is not zero. Let's give a little bit of background. So now what is happening: both the visuals, the 100% stacked bar visual as well as the stack visual can show you percentage as well as the value. Now it's your choice which one you wanted to use. You want to choose the 100% stack bar visual or you want to choose the normal bar Visual and then want to show percentage. I told you how to get a measure for that, which we will learn when we go to the percentage of total later. And then multi-line or single line have single line, but if you make it single line then make it vertical, that's look much better, but it's going to take a lot of space, so I'm going to make it horizontal and multi-line. That is much better in this one. Now if we duplicate this on this and we change it to 100% tag bar chart, there we can go ahead and make this data label out as instead of multi-line we can make it single line. Now it looks better here. Plot area and background same thing again. Reference line same thing we want to add. Then we have only one option: constant line. We can add constant line if you want a value, let's say 0.5. 50% is the one where I wanted the value to be appearing, and in this manner we can 100% stack bar visual. Again, the uses of the stack bar visual will depend on your us whether you need 100% stacked bar visual or simple stacked bar.
Now going to create the pi visual, so let me add another page and in this page uh from the build visual I'm going to add the P Visual, and we have a very similar visual donut visual also, so at the end I'll just show you the donut visual. So let me click on the pi visual. Now when you have the pi visual, the options you have is the legend value details and Tool tip. A pi visual can be created with a set of Majors or Legend plus major, so I'll tell you first how to create a pi visual only with measures. This is something which you might need. I'll create with the cogs discount and margin. Okay, the cost of goods sold discount and margin I've have taken three Majors, so basically what I can do is I can take net discount and margin. In this manner I can create a p visual which can tell me how much each of these things are getting contributed and you are getting percentage. So only with the help of major I can create. This is one way of creating a p visual. Let me move it aside. Let me add another P visual. Now we can have another Pi visual which basically I'm going to use Legend This Time, so let me use Cate as a legend, and ideally speaking because there's no scrolling you can have in the pi visual, you should use only Pi to 10 categories Max 15 categories in the pi visual; more than that it's overloading of Pi, so I drag the category and now I can drag a majure. Now values you should avoid using percentage column in this one because it is further going to calculate percentage of total of that, so that's not a great idea to have. So Pi visual has been created with Legend uh can we have more than one Legend? So let me also drag brand on top of it, and as soon as I add brand the one is the drill down structure has came. Now I can go to the next level; it is brand wise come up. I can expand both brand and category would be available here, so this is one manner. Second is this brand instead of having it in the legend I can have the brand in the details. I can click on add data instead of dragging and dropping it and I can have it here. Now in this case you can see they are not getting uh different colors; there is a distribution of brand is coming inside the same color of the category. In this manner also you can create it, so this is one way and let's keep them side by side so that you can differentiate. So this is one way where and I'm where you have it, and let me duplicate it so and this is the second way where we actually have the brand as the second legent and we expand it and you have this and you expand it, so these are the two meths here. Everything is going to get different color, and here we have the same color in which the brand split is there, and when you use the tool tip you'll be able to see.
Now let's play with the label now. So if you see by by default the detail label is on, and if you see the detail label right now it is showing data value and percentage. This is same true for here, but if you go here you can say all the labels, and here you will be able to get the brand name also, so which brand is there, so within the category which brand is there. Now a same way if you go here and if you enable all labels, then you will also get the the name major name and the value and the percentage. Now we'll keep the simple visual. Let's me create one more copy, and here let me remove the brand here, and as you can see we can get category the value and the percentage value, and we have the various options like only data value, only percentage of total value, or only category level or all the details. And then right now it is outside; you can say inside, and now everything can come inside, so you can always use prefer inside or prefer outside, so you can say prefer inside or you can say prefer outside, so it will try to adjust some of the things to get more values. Now this is the detail label, and inside the values again you have the font you have the color which you want to use. Background is auto; if you want on or off, you can say background is on, then display units is auto; you can say use none. Now this is for the value, so basic Bally then you have the value decimal places because if the value is an auto format about how many decimal places it need to have, then percentage decimal place value also you can control. Now it is one decimal; it is two decimal, so all those you can control. Now depending on the space the label may come little bit less or more, and then dot dot dot might start coming. Then there is something which is also known as rotation. Now rotation is basically if you see right now it's starting from this position. Let me highlight that for you. Right now it is starting from this position. Now if I do the rotation here, here the position starting position is changing. Now you can see that it is starting from here. Now same way I can completely rotate it, and if I rotate it 360 it will come at the same place. So this SK can be helpful from where you are starting.
Now let's look at the other properties uh we similarly we have a size and this horizontal position property. Padding is something how much padding we have in the space which is available inside the chart. Background on or off, we can switch it on and off, or if you need background we can change the color or we can change the transparency. If we have the color, we can increase or decrease the transparency based on that is visual border. If you want a border, now if I come out none of them has border, only this one has a border. Shadow if you need. Title the title is already there; we can have a title and then we can have a subtitle, then divider and spacing as usual, same as other visual. Legends again we can have the position top right top left and Center depending on the place you have you can adjust it because right now I created a little bit rectangular, so I do have a position in the center left or center right that I can use. Then the title again, the title is right now category; you can change it to whatever you want or or you can disable the title here. Then slices for each slices you have the color again. The P visual use Legend. So in the slices you have the color which you can choose; you can manually go ahead and change it uh conditional formatting is not supported, but I will tell you later that you know there is a work around to support initial formatting in pi visual. Now detailed labels we only option we have is the label is detailed label, and we have certain set of options which we can use, then value and percentage formatting we have done. So this is py visual for you, so uh you can create it with Majors, you can create with Majors Legends, multiple Legends, Legends and details, all those thing you can try out, and finally you can also have a donut instead of this one, so you can have the donut instead of having the pi Visual, and the properties are almost similar, so we have title Legends inside that we have options slices detail label; we can have rotation. Now sometime what we do we keep this as a transparent and behind that we keep a value in a card Visual and we start showing that value, so it start showing like there is a value in the middle that we can do, and if you want to add something additional on the tool tip, let's say margin percentage, you can add it and you will be able to see. Let's add margin percentage; we have added margin margin percentage I'm adding, so you can have n number of such uh things on the tool tip which you want, and then as usual the generic properties you can switch off the tool tip and it will not show the tool tip.
Let's experiment with a new visual, the visual which I want to experiment is the three map visual, so I'm going to add a new page and let me rename it as threee map. Some of the pages I'm renaming even after closing down the video for that particular visual, so you might find that some of the pages has been renamed. So I click on tree map. Now tree map is kind of a horizontal P; the only thing is it doesn't show you the percentage, so we have a category, but unlike P we don't have a legend concept here. We have the concept of category details and values, so first let's start with category, so we can say brand is my category and net is my value, and then we can enable the data labels, so it starts showing the values. If you go down in the data labels, it is showing what values it's showing, so value display is Auto, and you can see the values are out here. Can see these values; you can not it down here now and make it none so that you can see it in the default format. Similarly, you can play around with the other properties like font face bold italic underlying Etc to make the labels appear little bit differently. Now let's say in case I wanted to have more than one level, I can go ahead and add category also, and then we have that option like next level only on category or we can expand it, so we have both brand and category, and in this case you will get different different colors. Now going going to the color you have option like FX here, so at least so whenever you are using the categories you can color it means you have the single category uh then you can have the brand colors using using the conditional formatting, so you can control on that, but definitely when I'm going to use detail will I get that option or not, so let me remove category from here and let me add category on the details. So once I add the category on the details, now you can see the FX option is no more available for you to do the conditional formatting, and the brand itself is cut down into multiple categories and I'm getting the option for categories and the values. Now here in this place because I have now place where you know a lot of values are there, so it's better to have a you know Auto display so that you know the display becomes smaller or maybe we can reduce the font also, and category labels are also there. These are the category labels, and we can reduce the font of the category label also, so the uh category as well as detail label will become a little bit smaller if we use the category label here. That's controlled by here, and then we can choose the color or we can leave it whatever it is. So these are the various option. Again, if you want to have additional information on tool tip, you can add it on the tool tip. Then we have size title Legends as usual, so Legends are off, but you can add the Legends if like Legend is nothing but your category display, so here you are seeing that, but definitely the position seems to be very important here. This not conveying much of the message, so left center right is place where I can put it. It taking little space, but at least I'm able to see all the labels, so legend legend have a title here. If you want to switch off the title you can switch it off. There's no title here now. Then we have data label which we already explained and the value label as well as the category label which we have already explained. So this is our tree map visual. Let's now explore the line visual. I'm adding a new page and let me rename it as line. So line visual is given here in the build Visual and it is also available here on the top insert in the homepage from any of the place we can use it. Click on the line visual; it will give you a line visual. Let me make it
A little bit larger, we can have x-axis, y-axis, and secondary y-axis. Now, we have not used the combo visual where we can have a secondary y-axis, but line visual has been enhanced in the past to have secondary y-axis. But here, now there are limitations like when you can use a secondary y-axis. But so, when you have multiple measures, you might not be able to use it; when you have a legend, you might not be able to use it. So we have to explore that out first, start with a very simple visual.
Now, unlike some of the tools which doesn't allow you to align the non-time series visuals—means it's always need to be a Time series kind of a visual—in Power BI, there's no limitation. In Power BI, I can create a line chart just like a bar chart. So let's say I can have brand on my x-axis, and I can bring in net on the y-axis, and I can have a line visual which is very simple. And again, if I need more than one line, I can have that, but line visual is definitely more suited for trends. So let's bring in date for that. I'm removing that, and from the sales table, I'm bringing in date.
Now, as you can see right now, date is showing a hierarchy, and this is what we call auto time intelligence. Because of the auto time intelligence thing showing the hierarchy, so there was an option in the starting, if you remember, was auto time intelligence which we have not disabled. If you disable that, that will not come. Also, right now we have not created a date table, but when I'm going to create a date table and I'm going to join these with a date table, if they are joining with a table which is having a date this column, again going to join with a key column, then it will lose the date hierarchy. So in case you wanted to continue to use date hierarchy, you can duplicate if this column you're planning to join. So let me bring in that into the x-axis, and as you can see, it is showing me a date hierarchy. Now, if I want to keep date hierarchy, it's fine; I will see these options like, you know, drill up and drill down. So it can start with year, and then I can, you know, further go down by press drill down by going like this, or and drill up, or I have an option to expand and finally at day level. This is what I can do, or I can click on this arrow. Instead of date hierarchy, I can use simply date. When I use the date, you will see you are still seeing the same value, but now you don't have a drill up or drill down option. So that option is not available with you. You are getting is a continuous visual.
Now, what is this continuous visual? Now, this continuous visual is possible both in case of bar as well as line. Now, this continuous access is coming in x-axis. We have a type continuous and categoric. Now, when you have a date or you have a number, you can get this option, categorical and continuous access. Also get this minimum maximum range in terms of dates also, which we have seen in the y-axis. In terms of value, we have the minimum maximum range in terms of the date. Now I can make it categorical, and now you can see all the dates. And now we have to make the access a little bit bigger, or we can change the format of the date. So right now the format of the date is like such a big format. I can make it as a short date. Now I can see each and every date. And now, because the visual is too big, Power BI is automatically giving me scrolling; it can't fit in. You remember when it was continuous, it do try to fit it into the single page. I can make it continuous and categoric. Now, the option of continuous categorical is limited to date and the numbers. Right now you're saying this is coming in the ascending order, but you can use this invert axis; it will actually start it in ascending order. Actually, when you have the continuous axis, you don't have an option, option to sort it on the using the three dots. So you can use this invert axis option.
Now you can go to the values. Inside the values, the values are right now on on the x-axis. If you want to hide those x-axis values, you can use this. Now again, the display is auto, and then you have a title. You want to remove the x-axis title. Now you don't see any sales date here on the bottom. Now there's a sales date. Similarly, for y-axis, you have minimum maximum range, logarithmic axis, if you need, invert range, if you want to invert the range. On the top and 70k this case at the bottom, the direction has changed. Let me invert it again. Again, the values, you want to show the values or not, you can switch off the x's. You can pay attention to the y-axis; there's no values. Now again, want to display unit and everything, title. Again, we have the y-axis title; we can disable the title. Secondary y-axis, this is important. Now let's see, we have two measures; does it allow us the third measure on the secondary y-axis? I try to drag the discount on the secondary axis, and as you can see, we have the discount on the secondary y-axis. But when we have a legend, let's say I try to bring in category. Now I can't bring category on the legend. I remove the secondary y-axis and I try to bring category on the legend; I can't bring it. I can only have the category as a legend when I only have the one major. Let me try the category along with the one major. I have the now categories at the legend, but can I have a secondary y-axis when I'm using a legend? So let me try to bring in Gross on the secondary axis; I can't. So the case is when you are using a category, you can't use the line on the secondary y-axis. While if you're using a combo visual like clustered bar line visual or cluster stack bar visual, you would be allowed a line in the secondary y-axis along with a legend, but that's not allowed in the line visual. So that's the limitation, but yes, if you have multiple measures, uh you can still have one of them on the secondary y-axis. Let's bring in multiple measures and try to see what all secondary y-axis has to offer to us, and I'm bringing in COGS on the secondary y-axis. And in case it doesn't show you the secondary y-axis, sometime it happen that it might not show you, so what you can do here is basically enable the values of the secondary y-axis. So you I have added the secondary y-axis, so you will be able to show. Usually what happens is we columns like margin percentage on the secondary y-axis which have all together different range, so they create a different meaning. Now this could be a really complex chart if we do those things; things we should try to keep them as simple as possible. So I have removed one of them.
Now again, because this line axis is continuous, you have a lot of information out here. Then we have the legends, as I've shown you, you can either use legends or secondary y-axis or multiple measures, and then small multiples we'll check it later. Now in the legends, when you are showing uh the legends can also be for the major display; it's not only the legend. We can check their change their position. So right, I moved them into the center. Then the text font, you can change the title; you can switch it on and switch it off, like add legend title. I can say it's net by date. Small multiples options are not enabled because we are not using small multiples. Grid lines, in case we wanted to have grid lines, can increase the width of the grid lines, as you can see. Now I think we need to use a little bit darker color to make them visible. We can have the vertical grid lines if we need. Again, we need to have a color, darker color, so we can have vertical grid lines also here. Zoom slider to zoom your x-axis and y-axis. Now these are both continuous axis, so in both the axes you can have the zoom slider, and as you go down you will be able to see the dates here. So this is the advantage of zoom slider, especially in the continuous axis; you will be able to see the exactly going down to the drill down to the level, and as we have already seen on the y-axis, you actually goad and see the values on the y-axis by going down. Now secondary y-axis also if you need. So zoom slider, I can have on the secondary y-axis also. Slicer label and tooltip is few things which you can enable, and based on that, it's as you can see. Now there are two set of information, one which I initially had and one which is is changing over. So all these things you can use. I'm going to disable the zoom slider as of now.
Now for each lines you can have, you know, what color you want and everything. Again, conditional formatting is not supported, but uh uh if you go to the color you will see the margin and net, you can have the colors even if you use the one major, like right now I'm only using one major on y-axis, still there is no conditional formatting enable, but instead of conditional formatting you have a color dot which you can get, and that you can get when you come back from the bar visual by doing the conditional formatting on bar visual which we'll see later. Now there is something really really interesting, you can have the markers; you can switch on the markers here, and you will start seeing markers. Marker properties have been changed, and once we are done with the line and the scatter visual, I will showcase you those. Now you can play around with the size of the marker and you know the shape of the marker, but there are more things which you can do here is basically what you can do is you can go to your line style, and here like right now the line style, because there's too much of data, if I choose the line, change the line style, linear or smooth or stab. Stab actually you will not be able to actually see what means stab layout, but what you can do here is you can decrease that width, and ultimately you can actually make it zero; it will become like a dot chart. Now what you can do is instead of doing it for both the series, what you can do here is you can go to let's say margin, and margin I have a line and and I don't have a line for let's say net, so there's no line for the net, but there is a line for margin. In this manner you can play around. Now you can make it completely dot visual, or you can have a dot, and especially like if the majors are very nearby, I can have line one of the line without marker. So what we can do is marker right now is for all the series. I can go to the margin. Now because I have the line in the margin and I can say show marker off. So now what is happening here is the margin is only having the line, and there are Net series which is only having the dot. Now this is the play around you can do, and this is especially going to be a little bit helpful when you create the visual like line stack bar visual and line clustered bar visual where you can make your line to disappear and you can leave just leave the markers, so that can create more combination. Again, the marker colors you can control and change the marker color depending on like right now I'm based on the series I can change, but you have when you select all the it's not there. One functionality which is there, show all. Now if I switch it on on a particular date, I can show a different color of marker; that flexibility is there with us. Now this would be too many outside the dot now, but on a smaller data it will do going to make a sense uh that we have a different color, but let me switch it off, but you have that kind of flexibility here on the smaller value. Then the data label, we can switch in on the data label, and the data label have all things like we can have title also along with the data label. The values can be controlled; we can have a different value basically in the label. So I can have a different value of I'm not using gross here, but I can use a gross in the value, so the gross will get added in the label instead of net, and then I can add a detail. I can have another column in the detail; it will start showing two values. In this case we can have a complicated value display, and then then again single line or multiple line. I think in this case it's better to have multiple line because you have too much of information, but again uh we have to control the density uh here because the line chart is too busy. Can duplicate this here. Let's go back to the visualization and make it as date hierarchy and let's scroll down only one. Now this is the place where you can have you can play around much with the labels. We have the gross value; you have net value, so we are displaying the net values. Then we can add the details. In the details we can add the discount percentage value. I'm adding a discount percentage also, so I'm adding these values, and you can see these values here. Then we can have a background to these labels, and now as you can see here when I see the margin, the percentage seems better, but not along with this one. So let's go down and and we go to discount percentage p and we will say none, so it will follow that format. And if I go to the values again, I can say none, so it will follow the actual format. This is net and discount, net and margin. This is net and discount percentage; this is also net and discount percentage. So the two labels are shown for both the serieses, and if you want to control that in instead of each one, you can choose one particular series for which you want to decide whether you want to have a title or not. So like see I've added a title only for the below series. Now in the values, do I want to have this net value or not, and do I want to have details? Let's say I don't want to have details in the Net series; I don't want to have background, or I want to have background with a little bit different color in the Net series, so that I can do. I have a different color background, or let me change it a little bit different. So in this manner what's happening, I can control the label of both the series separately, and I can display different kind of information for each series. Now series labels, if you want to switch it on, so series label is something which is shown at the end of the line. If you see here we have seeing margin, and here we are seeing net. Now there is no line; we have made the line width as zero; that's why though the last value is appearing here. So at the last value these series labels are shown. Now again you can control like, you know, what you wanted for the net value. So you go to the net value, what color you want, and what do you want a background. So I given a background on the net; there is no background on the margin percentage. So this is one thing basically when you have multiple lines at the end of the line you want it to show what the label of the line and you want toase the information there. Background again I have enabled, and then you can change the transparency. Plot background area, we have seen; we can add the image here. Again, reference lines, there are multiple options. Now x-axis constant line. This is something x-axis constant line is going to appear when you have the number numbers or the dates, and like on a particular date I wanted to have a line, and I can add multiple such lines. So this data is from 2018-19, so I can say, Okay, I want a March 1 March; I wanted to have a line. You can see there is a line on the 1 March. I can get, and then you want to have let's say one more line, you can add one more line, and now you can click and see this is my one line. This is my another line here. Again, I choose x-axis constant line, then in the line I'll go ahead and give a value, so I'll go to again 2019, let's say December 31st. I got another line, so I can have these multiple kind of lines, and then definitely color line font, actually shaded area on, so that particular line can have the area before that line is a shaded. So what we can do is we go to the shaded area, and this is before or after. I can do what I can do is I can make this color a little bit more transparent, and now let me do one thing. I click on this particular line, the one before it. Now I again switch on the shaded area, now before, and now you can see this is I'm able to differentiate between this area and this area, just the way I have done the shading. In this manner I'm able to locate, and now what I can do is I can also change the color a little bit, and I can increase the transparency also. Now you're able to see the two shaded areas. So this can help us to give the shaded area between the lines, so you can utilize this. This is especially useful when you are using the kind of visual where we have the x-axis constant line, those which are on date and those of which are on the number, you should be able to get these. Now again you have the data label option here. Label is for the lines, so you can have the so whenever these lines are there you can see there should be some data label. This is the data label, the date which is appearing, on which date actually it is there. Now right, left, above, data value, auto, all these things are there. So if I disable the data label, you will see that now the line is not showing what date it is, but I can have the data label enabled. I can say right hand side have the one data label, and this is for each line. So I enabled for the one line, and now I go back and enable the data label for another line. For both the lines I have the data label. Then we have error bars; we have already experimented with that. If you want you can enable those error bars, and then you have to choose up bound, lower bound, and all those, and then finally you have find anomalies which is not enabled right now based on what our selections are. We rename this as line one. So these are the various stuff you can do with the line visual.
Let's have a quick look at the area visual. Area visual is very similar to the line visual, and we have two kind of area visuals: one is area chart like line visual with the shaded, and then we have a stacked area chart. So let's explore these two. I'll click on area chart on the build a visual, or I can click the same in the insert portion of the Home tab to get it. I'll add brand from the item here and net major from the base majors, and as you can see, I got a chart where I have a shaded portion below. Again, I can have multiple columns on x-axis; I can have a secondary y-axis; I can have a legend, and similar kind of limitations what we have seen on the line chart would apply also here. So let's quickly see what happens when we put a legend. When I put a legend here, you will be able to see multiple lines. Now usually when you create area visual with the date access, then you will have continuous data even for categories, and in such cases this visual will look much better because you will be able to see continuous lines for each categories. Now in this case, because each brand does not hold every category, you are seeing those discontinuous areas, and it is not conveying the message you wanted to convey using this particular visual. So in this case, because not all brands have all the categories, doesn't look so great. We will take an example later. Now similarly, I can also add a major on the secondary axis and test it out. So I go to drive measure and put margin percentage on the secondary axis, and now now you can see there are two area charts, and one of them is appearing.
On the secondary axis, I can also go ahead and enhance my x-axis by adding another category. Now, the moment I add the category, the default option is "concate label off," which we have seen in the line visual also, and "sort ascending." But we can go ahead and change the setting if required. If you don't want this expanded, we can actually use the drill-up button and can go up to the "hery"—we'll see only brand. Then we can either do a drill-down; we can go to the next level by looking at category; or we can have expanded mode like we got initially.
Now, I'm going to open the format pane on the right-hand side pane. Because of my settings, I'm able to see the format pane here, and we can go ahead and look at what all options are available here. Size and style are the common options which we have. Padding of the visual—uh, inside this one—how much we want, like from top and bottom, we want to reduce something. We have background. If you want a background, we can switch it off. If there is transparency which we need, which is 100%, if you don't have a background, it will also act like a transparent visual. Border, in case we need the border; shadow, in case we need shadow. These options we have explored in other visuals.
Same as other visuals, we have title. Again, you can use a measure inside the title. You can set headings font; you can also have a subtitle. You can use the divider to have a line between the title, subtitle, and the visual, and you can change the spacing between the line and the label, and you can customize spacing if required. On the x-axis, you can disable the values if you want—like, I don't know, to say whatever it is—you can have a visual like that. You can enable that; then you can only disable the x-axis title, which is "category" is only missing if you pay attention here. I'll enable it again. Same way for the y-axis, you have options like minimum and maximum, where you can use measures because the FX button is there. You can give static values; you can make it as a logarithmic scale if your values have too much of a difference. Usually, we use logarithmic scales; let's say one value is pretty large and another are pretty small. Then, in such cases, a logarithmic scale will give us a better-fit visual, which will be able to showcase the smaller values a little bit larger. Because of the logarithmic scale, we can invert the axis: the smaller values on the top, the larger value down. Then we have values which we can hide on the y-axis. If you can see, now there is no values which is up here, near to the net; there's no values here. Again, we have an option for font color, which we can change. Again, the color of the values can be based on a measure. Title: if you want to disable the title, you don't want to show the title, you can do that. Secondary axis: if we have a secondary axis, we can set up the properties for that. If you're using a legend, what position you want the legend, then the text of the legend, you can have font; title of the legend; you can enable/disable smart multiple—we'll try that a little bit later. Grid lines: in case you need grid lines; horizontal grid lines is enabled, but if I—vertical grid line—again, I have to make them a little bit larger for you to see. This is the vertical grid line for the axis. We have a zoom slider, which we have already explained in other visuals, but we can have a zoom slider, and once you have the zoom slider, you will be able to zoom the values.
Then we have the line option. Again, an area chart is definitely an extension of a line chart with the shade, but you can go ahead and play with the shaded area at transparency here. As you can see, I'm using margin and net. Again, just like the line visual, I am not having any option to conditionally format it. And then again, stroke, which is something which you can play around with. You can make it zero, so there would be no line in that case. I have done it for both, and then transparency: you can increase or decrease, or you can go ahead and choose an individual line. Let's say if I choose net, and for net I can have a line; there is no shaded area option for individual. It means the shaded area transparency can only be handled at the all level, not at the individual series level. Then we have markers. Just like the line visual, we can enable the markers; we'll get dots in the above one. As you can see, we don't have the line, but we still have the dots. Then we have the size of the dot, which we can increase or decrease; then color, if we want to change the color from the default one. Data labels: if you want to enable the data label—this chart is having too many values, it is looking busy—so you can say, okay, I don't need it for all the series; you can disable it for one of the series. Position: you can decide auto, above, under. Then you have the leader lines. We have the concept of leader lines, which we will explain to you a little bit later. Under the data label, we can enable or disable data labels by margin. So, let's say for net, I can disable the data label; for margin, I can continue to have the data labels. And there's something really interesting, that is leader lines. So I can enable that to see those leader lines. You have to at least give 25 to 30 as a minimum offset; then you will get noticeable lines. So, as you can see, I have set the value at 35, and now I can see these lines. And as you can see, these lines move your values a little bit up in case of the label, and that allows you to see these values in a much better way. This feature actually creates a visual connection between each data point and its corresponding labels, and because of this feature, you will have a better experience, as you can see, values a little bit away, and then there is a connection. You can have the values under and above as you want; like, if it is under, then the leader lines will go down, and if it is above, the leader lines will go on the upside. In case you want a title on the label, you can have a title, but in this case, because I have too many values, it's looking busy. But these are some of the new enhancements which have come where we can have a title, where we can have value, and values could be a measure-driven value. So, though it is margin, but actually I can go ahead and put discount percentage; I'll start seeing discount percentage. So these are what we are called the measure-driven labels. Then we have details. If you want to add details, you can add another measure. Let's say I now, along with margin, I want to add discount; I can add it, and then I have formatting options, transparency, and all that. And in the layout, we can—want to show them in a single line or multiple lines—all those I can decide. So, right now, I'll remove the details; we don't need it for this particular visual. Similarly, you have series labels. If we can enable the series label, and as you can see, the series labels are available at the end. If you want, you can disable a particular series label. Let's say I want to disable net, and as you notice, now that there is no label for net, there is only a label for margin percentage. You can play around with the values; you can play around with the background if needed. Then we have the plot area background, where we can have an image if needed. And the reference lines, as we have added in other visuals, we can also have reference lines here, and those reference lines could be of y-axis: constant line, mean line, max line, average line, median line, percentage line. These lines keep on changing based on the visual you are using.
I've named it as "area." Quickly create a stacked area visual. I click on a new page, and here I'll add this stacked area. In this stacked area, again, there are two ways to create: either I could have x-axis and legend, or I can have multiple measures. So, let's say I wanted to have x-brand on the x-axis, and then I can have net on the y-axis, and along with I can have, let's say margin, let's say create an equivalent of gross. Or in case I don't want it to have the double, I can use a legend also to have this stacked area. This will not look great. Again, for this purpose, I need to have something like date here for looking really good. So let me go to the sales, and let me bring in sales date here. And once you have the trend, you can see that it looks much better. And let me remove and make it only a year-quarter. As you can see, now it looks much better. Area visual: again, we have the similar kind of format properties which we can play around with. Because I'm using the date field, I am getting the access as a continuous option. I can also choose for a categorical option where I get the categorical values. I can change, add, remove titles on the y-axis. I can play around with the range; I can, in the text, font, title, same way, I can play around with legends and grid lines, etc. Same options are available for this visual also. Again, because I'm using a legend, you don't see any conditional formatting option. Anyway, we don't have any conditional formatting option in the area visual. Later, when we go to the conditional formatting, I'll also let you know how you can color dots in case of line and area visuals. And if there is a shade transparency you want to control, you can do that. We can little bit control it like this, or little bit lighter; you can increase the transparency or you can decrease the transparency. In this manner, you can create area and stacked area visuals or charts.
Now let's discuss the scatter visual. In the scatter visual, what we are going to do is we are going to discuss the scatter visual right now. When we go to conditional formatting, we will learn about the quadrant part of it, and also regarding the markers. What we are going to do is marker properties; we have a separate video on marker properties. There we are going to explore marker properties in detail. So I'm going to add a new page, and on that new page, I will add this scatter visual. Scatter visual is available here in the middle; click on that. Now, scatter visuals have many types. The best way to create a scatter visual is having both x-axis and y-axis as a measure, but there's a possibility of having a scatter visual without having a measure on the x-axis. So let me first give you that example. So I will take brand from item; I put that on the x-axis, and then I take a measure, let's say margin percentage, and I put it on the y-axis. This kind of becomes a dot chart; in a line chart, if you only have the markers and you don't have a line, you will get something like that. Another advantage which we will get over the line marker here is I can go ahead and have here a size for that. What I can do here is I can put gross on the size, so you can have smaller and larger bubbles. So this is one way you can create it. Then I have play axis tooltips. Now, play axis might not be applicable for the current scenario. What we are going to do here before we move forward and move to the scenario where we have both x-axis and y-axis on the measure, let's move them around. Now we have a scatter visual on brand and margin percentage. Can we swap? Can we have brand also on the y-axis? So let's try that out. Let me remove the brand from the x-axis and margin from the y-axis, and let me see if I can have brand on the y-axis. No, I'm not able to have it. So it means the possibility of me having a brand on the y-axis is not there. Let me remove the size again and try. So brand on the y-axis—so that's not possible; I'm not able to do that. Now what I'm going to do is the next thing which I wanted to play around with is having the x-axis as a measure, let's say discount percentage; y-axis as a measure, and that is margin percentage. So we have the measures now. Measures cannot give me a dotted chart; for that, I need—it's definitely something which gives me those series. For series, I can drag in City out here. City on the values; if I drag, you will be able to see the dots. Again, for size, I can drag in Gross here onto the size, and for size we have the format where we can, you know, play around and, you know, make the size smaller or larger. So marker is that for that, and usually when you have these kinds of stuff, I have found out that -27, 28, or -30 is a little better suitable size. So let me go to -27. So now this is a little better size in terms of what we want it to have. And then we have different kinds of shapes which we can take in the marker. So marker can control this size and the bubble, and we can have different kinds of bubbles also. Now, do we want it for all categories or a single category? That also we can play around with. So that is with the size. Now you can also have the conditional formatting done on these bubbles, and for that you have the option available under markers only. If you go to the marker color, you can see the f sign here; it means I can use a measure out here. That we'll explore a little later in the conditional formatting. I can have a legend, and once I have a legend, then I will not be able to change the color of the marker using conditional formatting. So let's say if I want to have a category as my legend, you can see for each category I have a color, but inside the color of the marker, now you don't have any option to change the marker color dynamically using the conditional formatting, but it allows you to have both City as well as the category in one particular visual and have the data at the city-category level, or you can have City-Brand level, State-Brand level—at that level you can have data. So you can add more detail by using a legend, or you can also do—let's say we drag the category inside the values only—so I dragged it, and then we can expand it. The moment you have more than one value in the values, again the same way you will get the expand option as you were getting previously in case of bar visual, pie visual, or line visual. So here, expand is a better option for us; we can definitely go to the next level, or we can go do the drill-down, but let's go and expand this. Now you are seeing the City and category, but is still the FX option is available. As you can see, the color of the marker is still available. Now, with the FX option, it means I can do the conditional formatting; I will be able to change these bubbles using the conditional formatting logic. So that gives me a little flexibility to have more than one granularity, and then I can use the color. These are some of the play-arounds you can do with the scatter visual.
Now, to take this next forward, let's see can we add a play axis? Most suitable play axis is basically a time range, but right now we don't have a date table, so but we would still like to see if we can put State on the play axis. I'm able to put that, and let me play around. So for each state, now you can see that I'm able to see the data, and you can do the same with the time ranges, month here, dates, and everything, and it will play for all the values one by one, so I don't have to do anything; I just play. We have created the visual; we have seen how to add the play axis. Now let's remove the play axis also. Remove the category; just keep it on the City, and let's start exploring the visual properties. So we have size and style; basically, it is dependent on what size we have, what location we have, based on that this can be changed. This is just the positioning which we have. Then the padding—basically the space on all four sides—background. Right now we have background on; if you have background off, it will take the color from the background of the canvas. Right now, when I—when it is on, it means the visual can have its own color, and you have to reduce the transparency to see that color. As you can see, if I'm reducing the transparency, I am able to see the color. I can have 100% transparency, or I can switch it off even if I don't want to have, along with the transparency. Then I have the visual border, in case I need a border for the visual. So if you click outside the visual, you will be able to see the border. And then for border, you can have the rounded corners if you want, and you can have width if you want to increase the width of the border. I actually don't need a border, so I'm going to switch it off. Then you have title, as usual, for every visual you can have a title. The title can also come from a measure, so if needed we can have a from measure. The headings, from normal heading to heading six, we can have any headings; we can decide the font and the font size, bold, italic, and underline for our titles. We can decide the text color of our title—let's say other than black, if I want to have some other color, I can have that. I can have the background color also for the title, it means only the title will have its own background color, as you can see. Then we can align the title left, center, or right, depending on the need. And if the title is too long, we can also use the word wrap property. By default, it is on; we'll keep it on. We have seen this subtitle property. Now you can have a subtitle other than title. The moment you enable it, it creates an additional row where you can have the subtitle; you can have text, or you can use the FX function. FX—it means you can have the subtitle based on a measure. You can have the heading, normal H1, H2, H3, H4; then you can have a heading two, adding three, heading four, whatever heading you want; on font size, bold, italic, underline; you can change the text color again, alignment left, center, right, or wrap text. I don't need a subtitle, so I'm going to disable that. Then we have a divider. Divider, if you remember, is going to come between the title, subtitle, and the visual. So title, subtitle is one party, and the visual is one party; then we can have a color; we can have the style; and then we—we can increase the width of the line, so that we can see the divider between the visual and the headers. I'm reducing it now. Again, I'm also going to remove the divider. Then x-axis properties, because we're going to use measures, so you can have minimum and maximum range; you can have a logarithmic scale; you can invert the scale if you need it. Inverted scale means the numbers will come from bigger to smaller. So if you can see now, 26% is before, and then 24, then 22, and then 20. If I revert it, it will start from 20 to 26. So that is possible here. This is the x-axis. Then we have the x-axis values, where you can go on the font color. Now the color can again come from, based on the conditional formatting, we can bring in, but we have to remember sometime the x-axis labels only work on grand total, so we do have to check that out. And then display is auto; we can change the display as per need; value, decimal places—because it is a measure, we can have value decimal places. So blank values is off, but if we need it, we can add it. Title: x-axis title; if you want to disable the x-axis title, you will not see discount. If I enable it, you will be able to see discount. So the play around is here for the title; the discount is going and coming back. Same way, y-axis. Again, y-axis is a numeric axis, so you have the minimum and maximum for the range, logarithmic scale, invert axis. Again, this axis can also be inverted, and this is going to be useful sometime when we specifically create the quadrant; it could be really helpful when we actually want high and low to be on a particular quadrant, then it could be of real help. So margin—as you can see, now the scale is inverted; we have from smaller to larger on the scale—in a
Reverse manner, same way we can play around with the value, font, font size, bold, italic, underline. We can use the function to color; means we can use conditional formatting. Then we have, have the value decimal place because it's a number. Then we have switch AIS position; means we want primary AIS, which is right now on the first y-axis. Margin is there; I switch it, now it is on the second y-axis. You can see it on the right-hand side, back on the left-hand side. Show blank values, in case you want to show the blank values. Title again, the title margin percentage; you can observe it is written, but if I disable it, it is not there. Again, enable it, it is there. Same way we can, if you need it, we can have grid lines. Right now, horizontal grid lines are, they are, they're pretty light right now. If we want, we can increase its width, and it will be made visible, as you can see now, but I'm not very fond of that, so I'm going to reduce it. Vertical is on; again, we need to increase the width to see them. Again, not very intuitive in this case, so I'm going to reduce it again. So these are the properties of basically AES. Now let's move to the zoom slider.
Zoom slider will actually give the sliders on the axis. You can have x-axis slider and y-axis slider, and then you can, you know, scroll them to get the values. This is really helpful when you wanted to have the sliders. Then, if you want to have the slider labels and Tool tip, you can also have that. We have played around with that in the past. Markers, we have seen basic marker properties. We have seen the marker type; I can change it to different type of markers. Then we have uh range scaling, Auto magnitude, data range. We can say, Based on data range, so you can see that, you know, the dots are little up from lower to higher. That is more suitable actually compared to any other thing. Color by category, on or off, so that is marker property which has came new. We'll discuss a little later. Then border for marker has also came; we'll discuss that later. Now category labels is something which is label, if you want to display basically the value labels. And now we have city, so we are seeing City label now. When we have City category, let's say what happened when we have the city category and we expand it, what would happen there. Now you can see City and category label coming together. We need to be very selective, in case we wanted to enable the category label specifically on scatter visual which is having lot of values; it may not be the best thing to have. Then you can have the category label can have background, so that they look little different. And once you have the background, then you can have background color transparency, etc. Then you have the plot area background; if you want to put an image, you can do that. Then you have reference line, and this is really important because that is where we want to create the quadrants. Here, before I do that, let me go ahead and disable the category labels.
Quadrants basically we can create by using the average lines, but I'll tell you the average lines are not most suitable. So let me go ahead and add an average line, and as you can see this average line comes in Middle, but the best, most, most suitable would be the constant line and use the same measure. But right now I added the average line, and the series is discount percentage. Let me add one more average line, and then this line is also going to be the average line, and for this one let me choose the series as margin percentage. As you can see both these serieses are available here, but if you use the constant line you will find out the difference. To do that, let's go ahead and do one thing; let's remove the second average line and then keep for the first one on the discount and on the line is fine. Let's enable the data label for this line, so we have option for data label, so I got this data label, and let me add one more line, and this time I'm going to add a constant line. So I select the second line, I'll go here on the type, and I'll select the x-axis constant line because it's on the ACC. By default it will come on zero, so I'll go to the line which is on values which is zero. I'll go to the FX; I don't want a constant line, but this gives me an option to use conditional formatting UI, which actually is the major selection UI for me, and here I select discount percentage. By default one major would be available for you to selection, and usually it is the x-axis major or the major which you are going to select for first time. So I've selected that line, and constant line don't work together; that's what my observation is. So what I'm going to do here is I'll go to this average line. Now remember the value 13.11, and I'll go to the constant line, and let me enable the value first of all, the data label. We will see that value, but this is right now not working, even using FX. I'm going to go ahead and delete this average line, and the moment I deleted you are able to see the constant line using the mejor which is actually the correct average; that's not the simple average. In this manner I usually prefer this constant line. Let me keep this, and then we have the properties like FX value, the color. So if you go to the reference line, you have the constant lines, then you have min, max, average, median and percentile line, which is most of them want to decide their values by themselves; you don't have any intervention in between. In constant line you have the flexibility to provide the measure, then you can decide the color. Right now I am having a color which is matching with my marker color, so I can change it. Transparency, dashed line style is dashed, solid, dotted or custom; I can have, let's say custom, then we can decide what kind of line we want. Then we have the width, width of the line right now is solid, and you can see width is three; that's good enough. Positioning, in front or back; means is it should be in the front of your markers or back side of your marker, that you can do. Data label, we have already seen; we have enabled it. Now the data label could be on the left-hand side or right-hand side. Vertical position is about or under, so we have, we have the horizontal position left and right, and we have vertical position which is above and under, depending on the need. So if we put under here, it will go through the down, and the same things will look a little differently when we have the y-axis constant line. The styl is data value by name; you want the name and both. If I want name as well as value, then display unit is auto; I can change the display unit here. So these are the various values around the reference lines, and that is really important here now. Then we have the symmetrical shading; if you want, you can switch it on, and you will have the symmetrical shading, upper portion Shing, lower portion heading, upper shading, lower shading, or depends on the visual; the it may have some part. Because in my visual right now the symmetric is coming this place, the reason is both of them are not starting from zero. If they start from the zero, this will make sense, but most of my data is in the middle starting around 20%, so that is why this is not the, and this maybe because I'm taking the data at City level; if I take a little different level it may be a different case. I'll switch off the symmetric shading right now. Then I have a ratio line; I can switch it on, you can see a ratio line now. You want, you can have a color, transparency, style, width etc. to that. So this is overall just a brief overview of scatter Visual and how you can design a scatter visual. There are play arounds with the, you know, quadrant colors and all those that we are going to discuss in conditional form.
Markers has been enhanced in October 2024, so let's have a look at what marker announcement has been done in this part. We are going to discuss the marker enhancement which has been specifically done around the line Visual and the scatter visual. Microsoft powerbi has done lot of enhancement in the visualization, and some of those enhancements we have not discussed so far. So what I'm going to do in today's video, I'm going to take you through one of such enhancements on the markers in October 2024. So let's look at the release notes of October 2024. So this is October 2024 feature summary, and if you scroll down here inside the content you will find out marker enhancements. So let me click on the marker enhancements to go down and look into the details. So let's look at the release notes in details. Marker enhancements: reamping the rendering of column bars, ribbons, line, area charts and marker is a top priority. These element form the foundation of our core Visual and will eventually impact other areas by provisioning more control. Our report creators can enhance their storytelling and help users easily to interpret data. In October 2024 update, markers for line chart, C chart and anomalies are Improv improved with this revamp. This update introduced new options that offer greater customization and flexibility. Explore these new options and maximize their potential. Marker for line and cluster chart can be customized now in two ways: categories; each and individual category like you have gen, Fab, Mar or brand one, brand two, brand three. When you have only single series or basically you only have xaes, let's say when your chart has no series, The drop-down menu displays category. You can customize each data points marker based on the selected x-axis category. You only have the categories; you don't have the legend or multiple majors in that scenario. Now series: when the chart displays Legend, the drop-down menu displays the series. The Legend series; you can customize the marker for the complete set of data points within the selected C. Overall you can change there; you can hide and show the marker for a specific data point category by toggling show for this category option. Please note the marker toggle has been moved under show for all series. New format settings have been added to the marker for each line, T catter chart and anomalies including shape. Shape of the marker continue to offer control over their type, size. Additionally, rotation is now available for all shapes and size except for the circle shape. Rotation shapes as the variety of shape type at your disposal, which is particularly convenient when multiple lies are required. Unique shape color; changing the color of the marker has been a convenient control. Now you can also modify the transparency of the marker for a specific category, series or all markers. Border: this is the new feature; border for the marker has been introduced, allowing you to add borders to specific marker, category, series for all markers. Additionally, you can fully customize the marker borders by adjusting their transparency and the width. So these are the features which has been released some time back. First of all, let's look into the detail is what we are going to learn today. So we will learn how to enable the marker, how to do changes at categories or series level, how to change color, size and transparency of the marker, how to change color, size of transparency of the marker B, and this can be done both at the series level or categorical level for both marker and marker border, so that we are going to understand today in details. So let's jump onto the powerbi and explore that out.
So I'm here on the powerbi desktop, and I would like to add a new page to start exploring the markers. So on this new page, first of all I would like to add a line visual, so item wise net. So this is the visual I've created, item wise net, and let me enable the format. If your format is not visible, you can go to the view; from there you can enable it. After that, on the, if it is still not available here, check out the rightmost side; is it disabled from there, or it has been minimized from there? These are the places where you are to look for. Now once I go inside, right now I have a single measure; I have only one series. I go down to the marker, and here you can see that I have option for categories; I can choose individual category or show for all categories. Let me enable show for all categories. Now I can choose the shape, so let me choose a little different shape; let me choose a triangular. Now I can increase the size; I can change the rotation. Let me rotate it by 90°, 92; let me write down 90. So I rotated it by 90. Color; I can change the color; right now it's very similar to what I have on the line; I change the color. Then I can go to the Border; Swit on the border. Now you can see a small line uh match with the series color will start matching with the series color; uncheck this and go ahead and change it manually. So let's say something like this. Now transparency; first of all let me increase the WID so that you can understand transparency later; I think five point is good enough. Now look at the transparency; when I decrease it, you can see the transparency, and I can completely wipe it off, so there will be no bottle. One way to hide is you completely make it transparent, so it will go away. So now what I have done here is I have done the transparency on the shape and zero transparency on the border, so you are seeing like empty markers. So this is one another way you can get like empty markers where you have no color inside or you have the transparency which is 100% for the inside. This is for the overall category or overall the complete x-axis series, but I can go to individual, and I can check it; let's say brand8. I can go and change it. So right now it is showing the same properties, but what I can do here is I can, let's say choose a different marker there. So instead of triangle let me choose a circle, so you can see now there is one Circle which is available; it is an empty circle because I have 100% transparency at the marker level. I can reduce it; now only this point is having color because the transparency is not there. So individually I'm controlling one particular category. In this manner I can do this action. Let's see what happens in case we add another measure. So let me add a gross measure now. So this is a net measure; now I add a gross me. The moment I do it, you see everything has been replicated for both the serieses, gross as well as neet. If you go here, now you have the only control over gross on neet; the category control is not in your hand, but whatever you have done previously is there. So it means in case you want individual things to be done at the start of the line or the end of the line, now it is static in nature as of now, but you can do that and then change your series or then add the series. Now here I can go ahead and, let's say choose gross for gross. I can go ahead and change the type to square; everything is changed to square other than, see look at this brand, moving ahead. I can go ahead and change the transparency for the gross to zero, so that I will get color inside my squares. Each series have its own type and can have its own color also. Now I'm changing the individual one, but brand Aid which we have changed previously using category is still remain, so that's a good thing; we can do it previously and then do it also. Go ahead and change the Border color; so in this case I can choose different color, and I can also change the width of the marker. You got a different look and feel for your markers; this will enhance the visual experience of your line. Now let me tell you one more trick for that; we have to go and adjust the line width. You can go ahead and reduce the line width to zero, so that line disappears; you will only see marker now. This is for all the series; you can choose individually which series you want. What I can do is let me have the width three, and let me go to, let's say gross and make it zero. There is no line for the gross; there are only marker, and it could be helpful sometime; you just wanted to show the markers, you don't want to show the line, and then you can selectively enable data label also and go to the series; let's say gross is on and net you can switch it off. Now you're only getting the labels for the gross. What I would like to do here is I would like to play around with the legend; means I would like to have not the major series; I want to have the Legend series. To do that, let me add a new page, and in this new page I'm going to add one more line Visual, and this line visual I'm going to have it on month year. Xaxis is month year from item Dimension; I'm going to take category as a legend, and let me take a major as that on the y-axis. Now as you can can see for each series I have a line; I can go to the markers, and as you can see I have a series; for each series I can have some kind of a marker, or I can enable the marker for everything. Now I enable the marker for everything; I go to the category one; I disable the marker, so there's no marker for category one. Now you can check it out here; there's no marker. So now let me go to category two, and for category two let me change the markers as triangles, and let me also make them little bigger. Same way I can go to category three, and I can change the marker to square, and and I can also make them little bigger. Can go to category 4 and choose X as a marker and make it little bigger also. I can change color for some of them if required; let's change the color for category 4 to the Violet for x, and then I told you the trick; you can hide some of the marker using transparency, or you can hide using goow for that series. There are few options, and you can have border if required. In this manner you can play around with this. Now what, let's do one thing; let's also experiment on the scatter visual; that's one of the very common visual which we use. So let me add a new page, and in this new page I'm going to add the scatter visual. Let me add to access which is my discount percentage; let me see the drive measures, the discount percentage and the margin percentage on two x's. Let me add City from the geography table as values. I have got a good number of cities. Scatter visual shows markers; what we can do is we can change the marker completely for everything, or we can change it for each category. Now as you can see I already have the marker open; so for all the categories I can have, you know, something. So first of all I would like to increase the size, so I let me make them a little bigger. Now I can go to a particular City; let's say I want to highlight a particular City, so I can choose a particular City in the category. So let me go to Los Angeles, and let me choose different shape for Los Angeles; I have choose it in a triangle. Now you can see one triangle into the middle. Let me do one more thing is basically uh right now the size is not govern by something; so let me govern the size by gross. Size is now govern by gross; now this is too big for size, so we need to reduce the size, so we go to the all. Now you got to reduce the size here, so we go to the size. Whenever I use gross, I usually take any value between -25 to -30 depending on the need. Now let's go back to the Los Angeles. Now I what I'm going to do, I've chosen the Los Angeles again, and I'm going to change the border. Border is switched on; right now it's matching color, so I switch off the matching color; I want it little different color so that I can highlight it, and let me increase the width. Now you can see the Los Angeles there with this one and color transparency; let me reduce it to zero, and I would also like to change its rotation, so let me change its rotation. I change the rotation to 97°, so it's looking like Arrow right now.
Here, in this manner, what can happen here is basically you can go ahead and do very special, specific stuff on your markers. You can change the shape for each category or series. You can change the rotation, color, transparency of the color. You can change the border color, transparency, and width. These are the various features which have been released as part of October 2024, so why don't you go ahead and try them out?
The next visual which I want to discuss is the funnel visual. So let me add a new page for that. Funnel visual is especially used in case of sales when we have lead opportunities and conversions. Now, again, there are a couple of ways you can have it. One is basically if you have multiple measures, you can use the funnel visual in that. Let me drag Cogs, Net, Gross. We also drag Margin here. You can treat this as your opportunities, leads, conversions. This you can treat like, you know, you know, total leads you have, how many are opportunity, how many of them are hot leads, and finally how many are converted, something like that. In this manner, you can get it.
Now, in case you don't want that, you can have a category. Let's say those opportunities are not in terms of the majors; it is in terms of the values, values in the rows. Let's say, let's treat Category as one of them, and I bring in Category here. And as you can see, now we have Category 2, Category 4, Category 1, and it automatically, you know, adjusts into that as that method. Otherwise, what you can do is you can go to the set access and, you know, you can say I want to certain category, so it can give it. But it's not going to make sense unless your categories are sorted in that particular manner, like opportunity, leads, hot leads, and sales, etc. If you are simply using numeric value, it should sort it in the best way, and then you can have sort ascending and sort descending to make sure the kind of visual you want to get, whether you want to get the funnel or you want to get a pyramid, based on that you can take action on this visual.
Again, if you want to look at the property of this visual, you have title, subtitle, divider, spacing, data labels on and off. So you, you can see the data into the middle of it; you can switch it on and off. You have inside, center, and outside as an option. Now you have data value, percentage of first, that is really important; percentage of previous. Then we have data value and percentage of first, and data value and percentage of previous. These options are available. I think percentage of first is something I want to keep, and for that I would actually like to have it descending. This looks much better to me. Values, value font and color, you can change decimal places; you can control, you can control the percentage decimal places in case you want to have a background. You can have a background. I have a little bit lighter background there on the back end side. Now I made it a little bit more darker so you can see it. Now category labels, the labels of Category 1, 2, 3, 4, here it is Category, but it could be anything else. If you don't want that, you can switch that off. Again, I'm switching it on. Then we have display conversion label option, that is the top and the bottom lines if you are seeing. So basically, this is 100%, and 24% got converted; that's what this means is. But if you don't want to display that, you can disable that. So this is for charts, mostly useful in sales and finance. Based on the requirement, you can use this visual to enhance your visual experience. Let me rename the page before I switch to the next visual.
The next is not a visual; the set of visuals which is basically the maps which I wanted to explore. And we have a few maps out here, and some of them are dependent on settings and the login, especially map and shape map visuals; they are controlled by the preview settings and the security settings. So let me showcase you the settings quickly once again. So I'll go to File, then I go to the Options and Setting, and Options, and I have Preview feature where I have the shape map visual, if you can see, which I have enabled. Then you have to go to the security settings, and inside the security setting, if you scroll down, you have to enable RGS map and field map visual. Now I have not logged in, and if it gives a problem on my tenant settings, you also need tenant settings to enable the map, and when you are signed in, it does create an impact. So let me first start with the map visual. I click on the map visual, and in the map visual I'll add State. I have two options only: State and City. So let me start with the State. State is part of my Geography Dimension. I drag it here, and with that I'm going to drag Net. It creates a bubble for me, and the, the moment I drag the Net, that controls the size of the bubble, and then we can do a little bit play around. Now, because this visual has a legend, and if I drag a legend, it will also create a pie chart. You can create a pie chart in case you need a pie chart. And then let's look at the properties quickly. We have the size properties, then we have the background, visual border, Shadow, title; these are the same properties, subtitles, spacing, Legends on and off. In case you are using Legend, if, if you're not using Legend, then that on and off option is not much useful. Then we go to Bubble, and as you can see, we have the size property which we can play around; we can decrease or increase the size. Now, depending on how much is your range, you can choose this size. Then rendering is magnitude, data range, and auto; there are small, small differences in that. Then color. Now, because, because I used Legend, I'll not get an option for conditional formatting, but if I remove the category from the Legend, I have the option for FX, means I can do conditional formatting, or I can change the color manually also. Then if I go down, we have category labels. If I switch it on, it will allow me to show the state labels or the category labels. I can have a background, or I can switch off the background. To, if I want to show only names, I can have color for the map. Now, if you go, if you want to have a heat map, you again have options for heat map, and you know, gradient 0%, how should it look; gradient 50%, and gradient 100%, how should it look; and then you can increase or decrease the radius to showcase, uh, the heat map here. This play in pixel, you can attend meter, and transparency, all these things you can control. I'll switch off the heat map. There is something known as map setting. So right now the map setting is Road, but I can have Aerial. This is how it will look like: Dark, Light, Gray Scale, and Road. And we have the option for show and off, show label, off label. So you see the labels, I'll let me highlight you which labels. Let look at these labels, and if I switch it off, you will not see the country labels. Then we have a few controls like auto zoom, which is enabled. So if I go here, I can zoom, or it will, what happen if there is some value get selected by some, some slicers or something, then also it will automatically zoom. So let me add a slicer externally and try to select something. Let me add it, City slicer. The moment I select a city, because of that state got filtered, and you can see that that got highlighted, and this is because of the feature of auto zoom. Then if you want, you can have zoom buttons. If you click on zoom buttons, you'll get this plus and minus which you can use for zoom in, and you can change the position. If you want to zoom here, then there is a lasso button. If I enable lasso, this is a really interesting feature. What does lasso select do? Is basically I can press the control button, and then I can select multiple values, and to what does it do for that? What I'm going to do is basically let me click here on this visual, make it as a table visual, and let me few cities here like using control and drag, and as you can see the values are changing. Let me do it only on Hawai. Here you can see only this value. If I click back in the any space, it will go away. I selected two of them. Again, click on empty space, it will go. Select few of them here on this side. You can see the values are changing. So this is the advantage of lasso select; basically with the control you can do the selection. You have to enable the lasso select, and geocoding is basically what kind of geocoding you want. If you want different cultures, you can use those. So this is what we call as map visual.
Let me add another visual, which is basically the fill map visual. Now in the fill map visual, we have location, Legend, latitude, longitude. So in case you have latitude, longitude, you can use. I don't have, so I can use City or State, but this is not a visual for City. Let's see, can we get it? I drag the value here for the shading. No, this is not the visual for that. This is a visual more suitable for States, so I can put State, and I have already drag one major based on that; it is giving me color. It's going to give one tooltip, but if you want to have the shading, basically what you can do is you can go here in the fill color, you can use the conditional formatting here, you can use okay, and you can get the conditional formatting here, then this one, and all those controls and everything is applied here. Now if you want you going to use a legend, and if you use Legend, you might not get the FX option in the color. So let me use a legend of Category here. Now this option might not be really useful; you do have the color, but it always ends up showing you only one category. We create something known as topper, um, first topper and second topper kind of where we can find out every category which is topper in each state, and there we can use this filter that out that only top categories are there. So we see rank one, and then it would be more beneficial for us to have this kind of visual. So this is the fill map visual for you.
Next visual which you want to explore is the shape visual. And the shape map visual is one visual where you can also have your own shapes coming in. So I'm bringing in State, but if you go here into the map settings, it is showing that it's a US state map, but if you have, these are the other state maps which are also available, but you can also bring in your own maps, or you can browse the map type. You can have your custom map, and you can browse the map, and you can use that. So right now we are using the USA map, St, but you can have your own map, and we have similar kind of setting here, but in this one you have the color saturation already available. So one of the ways you use color saturation, secondly you use the fill color. So if you go to the fill color directly without using the color saturation, you can have FX button, and in the FX button you can use, let's say gradient, and you can click okay. So it will give you the conditional formatting; it will give you the gradient based on that, and also you can use the conditional formatting like rule based conditional formatting or field value based conditional formatting here. But what you can also do here is you can have color saturation. You say, no, no, I don't want to control it; let Power BI controls it. You can put Net into the color saturation. The moment you do it, you will not get that particular option, means now you have the gradient which is, you can choose the color, and based on min max value, it's very similar to the gradient what we have there, but if you don't use the color saturation, you more flexibility to use conditional formatting where we will also be able to use, um, rule based conditional formatting or measure based conditional formatting, which is field value based. Then for the blank areas, no blank areas on or off. I use off, then you don't see the blank areas here; you, this is white in color, and otherwise you want to show it, or you want to show it in black color, you can decide how you want to show the blank areas. If you want to use Legend, again, Legend would be not very useful unless you plan to show the top ranker or second top ranker. We need to take an example of what do you mean by top ranker and second top ranker. What we need to do is we need to create category ranks, and then we need to filter the top rank, and that we will do once we learn how to create rank index, and then later on we'll come back to conditional formatting, then we will learn how to use that. So this is shape map visual, and really powerful in case you want your own custom shape, you can go ahead and try that out.
The next one which I want to use is Azure map visual. Azure map visual has recently been enhanced, and one of the thing which you must remember that it requires a sign in. So now I need to sign in before I use, and it needs to be enabled at my tenant level. So let me sign in. I have signed in into my popup. Let's remove this and try to add it again. It gives me a disclaimer also. Let's try to add some location to it. Those of you who used your map visual in the past or seen the past video, the location is something which very recently got added. So let me add a location here, but this visual is coming out as one of the powerful visuals that we can have here. Then we have a size which we can bring in using Net here. By default, it has given all the same size. Now I have the size. So let me go into the property of this visual. So you have the map setting where you have the style, different kind of style like Road, Hybrid, Satellite, Gray Scale, Light, Terra, Blank, Blanks, Accessible, High Contrast Dark, High Contrast Light; these are the styles available. Let me keep it Road only. Then you have View, auto zoom on, and you can have different options. If you want to disable the auto zoom, like, you know, you can observe the difference. The moment I remove the auto zoom, it actually comes in, and then you have the buttons which can control it, but I think auto zoom is a better option, so I'm going to keep it. But yes, you will get the zoom buttons; you will have the reset options, up and down options, and some of the options are available on the visual for users to change it. Then you have the controls. So word wrap can enable, disable style picker. So if you in the top if want to use, see this is the your style picker, and I, I can disable it, so you can't change it on the fly. Like if I give this, you can change it on the fly, but I'm going to disable that. Navigation buttons you have, I disabled that. Selection and switch on and off selection button. Geocoding is auto; I'm going to keep. Then you have the layer settings, which is minimum and maximum unselected disappear. You can have Legends. In case we are not using Legends as of now here, uh, we'll see the field map not applicable right now. Bubble layer is a category label. So we have the heat map option. In the heat map option, we can play around with the radius, and when heat map is enabled, we can switch off the bubble layer so that we only get the heat map layer. In this case, there are multiple levels, so we can disable this. Now we have the color option where we have the color of the gradient right now, which is applicable in this case. If we switch off the heat map, then that color option will go. Bubble layer is on right now. In the bubble layer, you have the cluster bubble, and then the color, and then we have the size of the bubble, which is minimum and a maximum. We can say minimum is five, and maximum we can also control. So we'll have a little smaller bubble. Range selected is data range or magnitude or auto; we can keep it data range, your auto. A shape transparency, we can control inside the shape, so I'll make it a little bit transparent. Color, you have the conditional formatting option. We have conditional formatting options, and we can do conditional formatting based on gradient color, rule based, or field value based. Let me try based on gradient as of now, based on the margin percentage, uh, it's rule based right now. I'll make it gradient based so that I can easily do it, or I can say based on certain rules I can have those values. So this is gradient based color. So this is all, all I'm doing for bubble. Then bubble can have border or not; you can decide, right? Switch on border, switch off border. You have the zoom option. Then you have the options which is pitch, alignment, viewpoint, or map labels are below or above. Right now I don't think we are showing labels. You can enable the category labels. Now you have the labels, and labels can have background or cannot have background, and you can add a heat map layer as we discussed. Now if we go here, can put, let's say Legend, I'll put Category as a legend. The moment I put the legend, you can see the pie charts; the labels are too big; we need to disable them. I'm disabling the category labels; you can see the pie chart better. As soon as I add the legend, you cannot have the color using conditional formatting, so that is gone. You have the border and the width of the border. If you want simply, you know, a totally covered pie, you can have the transparency. If you want, you can increase the transparency of the colors. You can change the size again; we can start with a little bit smaller and going to a little bit larger; you can control the size; you can control the shape transparency. Again, I want lesser transparency in this case. So these are the various options you can also use with the Azure map visual. Map visual is coming as a stronger option compared to all other visuals, and you're getting a lot of enhancement on that, so start exploring that. It may give you options which you have in other visuals, so it could act as a replacement of those visuals.
The next, uh, visual which I want to discuss here is card visual, very simple visual. So let's add a new page, and from the build a visual, I'm opening the Builder visual pane this time. I closed it, so I opened it by clicking on build a visual, and in the Builder visual we have this is card visual. We also have a new card visual which we'll learn after we learn the major because we wanted to create an icon measure for this, and this visual is also available here in the insert of the Home tab. So let me click on the card visual. We do, do have a multi-row card visual and the new card visual, but let's focus on this. So in the card visual, let's drag a major, and you can have one major only at a time. So I drag Net. Then if I try to drag Margin, and it will replace Margin, so I can have only one major. So I'll have Net here. Now I'll open the format by clicking on the format, and we have the size and the position which is coming because we dragged versus what we, how much size we have given. Padding is for the top and bottom. If we want a tight fit text, then we can reduce the top and bottom spaces. Background, we can switch off; we don't need a background. And in case you need a background and along with the color, like you want your background color to change, let's say my margin is positive, then it should be green and red, then you can do it using that. Then we have visual borders, uh, in case you need it. Shadow, in case you need a shadow, on and off, as usual, we have tried out in the past. Title. Now, sometime you may like to have title or, you know, want to have a category label. Like let me switch off the category label, so you can see the Net is not available now here, so there is no Net value here when
I switch off the category label, so instead of that, I may like to have a title which is known as net. I may would like to do it is Central align, and then I can have my card visual like this. Now you have the title; now you can have a subtitle here, but I don't feel a need for giving, but you have an option for that. Having a subtitle, then a divider in case you need a divider between the subtitle and the value. And then when I go to the call out value, that's why I created a little bit of space because in the call out value, I want to use none, so I can change my format here and decimal place. I'm also going to make it zero. My major do have a decimal place, but I can change the number of decimal place text WP. In case it is bigger, then we can have a text WP, then category level as we switched off, but if you want, you can have category level, then you need to give a space according to it. I think both are not needed. You can have the font italic underline in case you need that. Again, uh, we have FX like basically the name should change based on on the conditional formatting. Let's say if the net is passing some value, we want to have the label have changing its color or call out value changing is color. So you can see these FX option is there in the call out value; this is there in the category value; category label, it is there and as well as in the background also. This same thing is available; title also it is available; text color, background color, FX option, and background also we have FX option. In means all these we can use conditional formatting to change these colors.
So what I'm going to do here is I'm going to disable again the category label. This looks much better, and what I can do is I can copy paste this, and in this new one, instead of net, I'll bring in Gross, and it has taken the same properties. So this is a trick that you create a card Visual and set all the properties and then duplicate it for the s similar measures and use that. In such cases, you will require lesser changes in the new card visual which are coming in, and you will be able to use the same set of properties in multiple card visuals. Finally, go ahead and change it, and now I can use gross as a title here. In this manner, you will require a lesser amount of work to format all your card visuals. There are certain times we can do multi-select; some of the common properties are visible, and you can change those, so that is also you can do a faster formatting. So this is the card visual for you. The next visual which I want to discuss is the multi-row card Visual, and what I'm going to do is I'm going to add that on the my card visual page. So I opened again my card visual page, and this is the multirow card visual here in a builder Visual, and it is appearing here. I can make it a little bit bigger. Now, as the name suggests, it's a multi-row card visual, so one thing which comes to my mind that I can have multiple measures. Okay, so let me copy paste it, duplicate it, and let me see, can I have brand or category also as one of the field? I can have Category 1, Category 2, Category 3, Category 4, these kind of values, and so I can have a field as well as a measure along with that. So let's start formatting the and see what all the formatting options we have. The movement I used categorical field, it seems like I'm getting only vertical here; I was getting horizontal also. So in the first one, let's add a few more and see is this is the the style or can we change it? It seems like it do can do some kind of adjustment, but let's see how much control do we have. I clicked on the first one, and I'm going to change the properties of the first one. Again, the background is something which I don't require; visual border again we have learned in the past we don't require that; shadow we don't require; title is definitely, you can if you required you can call it KPI, KPI, or KPIs. Then again, bold, italic, underline, text color you can do; subtitle if you require; divider in case you need a line between these spacing. Then let's go to the card, so card we have a style which is top, bottom, left, right; these are just alignments if you look at it. So you have styles, your background, your padding, padding between these things, ascent bar, bar is something which is available here basically, and want to remove that you can can remove it, and let me do a little bit of adjustment here. And that's where the new card visual is much better here compared to this one because, as you can see, not much options are under control on the design in case of uh the KPIs, and that's where the new card visual is going to be a better option which we discuss in sometime.
Now let me go here uh in this one, and as you we have size, visual border, Shadow, title, call out values, then category labels is something which I would like to disable. Now if I disable, I will not see gross and anyway here I I don't want to see gross again and again in this one, but if you I want to have category label, I can have conditional formatting that can change the color. So here we have the conditional formatting options on call out values, and call out value is nothing but your actual value. So I can make it bold so that you understand this is what we call call out value. Category label, you've seen this is what you call category label, and we have conditional formatting available at the call out value level and category label label. Here I don't need the category label, so I'm going to hide it, but definitely we can use conditional formatting, so we can go ahead and say, okay, we need the conditional formatting based on let's say discount percentage, and we have discount from 0 to 25 maximum or 35 maximum, and we'll say okay, and as you can see the text has color, but all the colors are very nearby. Tell you a better way to know the range, so go here and add the discount percentage. So you can see the entire discount percentage is between 22.8 and 23.4. So what I've done basically, I set up the value between 225 and 235 and try to keep it, but as our values are pretty nearby, you will see that you know most of the values are having color which is very near to each other because these values are very nearby, or we could have actually done what on the margin percentage. If you take margin percentage basically, uh you have we have a little bit bigger range, but for categories we don't have, so these kind of challenges can come if your ranges are very nearby. So in such cases, you can use use field value base or rule based and call out explicit color which can differentiate that. We will learn a little bit later as you might have seen that I added discount percentage and margin percentage also. I can add here at this moment it is really important to know what category label it is, and I have to now enable the category label if I want to show it. So in the previous case, the category label was not uh required when I only have the one value, but now because I have multiple of them, it is required that I have the category level multiple purpose. So some of those purposes may not be easily served by the new card Visual, and one of those purposes is this purpose where I have a category and I then I display these multiple Majors below it, and this kind of display is something very specific to the multirow card. This is multi card visual for you.
So the next thing I want to discuss, uh, filter pan with you, and before going to the next visualization which is basically slicer, I would like to discuss filter pain with you because how filter pain applies and how slicer is going to be a little bit different from that. This is something I want to explain. What I've done here is basically from different pages which we already created; this is Matrix visual, this is the tagged bar visual, this is p Visual, and this is table visual. These are the same visual which we have created in the past some time back in the other pages, and from there I copy paste it and resize it. Let me open the filter pan now. Now let's try to understand what is this. So now when the no visual is selected, you see filter on this page and filter on all page, and you don't see any value inside it, but if I click on a particular visual, in this case when I clicked on the pi visual, you do see category, margin, margin percentage as the filters which is available; means both categorical variable and the numerical variable which is basically the majors, Majors as well as the fields or the columns are available for filtering. When I click on the table visual, you see what is be added. So typically what has been added is by default available in the filters of that particular visual. We can definitely go ahead and add a few more values. Now let me come to this particular visual in the category Visual, and if I want to filter something, I go ahead and filter this. Now as you can see, there is no impact on the other visuals. I'm filtering a value, and there is no impact on the other visual when I'm filtering from the visual level filter. So visual level filter only impacts a particular visual. Then the second thing I'm seeing some Majors also like margin, margin percentage here in this visualization. So let me go to this column net, and let me say the value is what are the options I have. So in the net I have option is less than, is more than, is blank, etc. So what I'm going to say here is basically if you see I have values which is basically 1.3 million, 1.7 million, 1.8 million, 2.5 million. So let me say value is greater than, and I'm going to write down 1.5 million. So this is 1.5 million value basically, and I say apply filter. So now you can see the it is getting filtered based on the value. One most important thing which you have to remember that you can only use major filter, the filter on a measure in the visual level filter only. So you can only filter measure at the visual level. Now there is one more which you can use here, and for that what let me do is let me simplify this table visual. I go to the table Visual and open it, build, and from there I'm going to remove category. I'm trying to simplify it, and when I go to brand, actually instead of basic filtering, I can do the advanced filtering just like I have done in the text major where I used Advanced filtering, not the basic filtering. So the basic filtering is basically the values I can select Brand 1, and I can also select Brand 10, Brand 11; that's my basic filtering, the values filtering. Then you need Advanced filtering. So in advanced filing, I can have contain, uh does not contain, but I have very similar. So I can say Okay, contain one and apply; all those which contain one will come. Now as you can see in the contain, I can have contain this or this; there are only two options, but if you need multiple contain, what you need to do. So in case you need more than one values in the advanced filtering, what you do is go to the basic filtering. Let's say I need three conditions, so check out three here and then go and say advanc filtering, so you will get three conditions there, and now you can say is and does not start with or start with. So and and or combinations you can create. So we can say is Brand 1 or is Brand 10 or is Brand 11; that's the three values basically in or multiple selection, means that add; otherwise we can say or contains or start with. We say or contains, let's say two; either it is Brand 1 or Brand 10 or it contains two; we got a different combination. In this manner, you can have multiple conditions and and with the Eraser with the help of the Eraser here you can actually remove it. So now you understand the basic filtering, selection of values, Advanced filtering; you have lot of options, and the options would change based on whether it's a number or whether it's aing data type. You can have like contains, does not contain, is not blank, blank is really important because is blank or is not blank or empty values when you don't have the values it is going to help you out.
Now the Third Kind of filtering which we wanted to discuss is the top end, and the that is because of which I actually I also removed the category because I want to explain you this easily. So you have something known as top end filter. In the top end, you can specify I need five. Now five based on what? Let's say cogs, discount, margin, margin percentage, let's say net; I'll bring in net here. Now remember, right now you are not do net here, but I still based on the net I want to filter, and I'll say apply. I ask for top five, and you might be surprised why it is not G toet price. The reason for that is this quantity because the sales quantity is unsummon summarized. So I'm going to remove it, and now you're only going to see five properties. I don't have net inside this visual, but still I can do it. So this is top five based on net. I can change it based on margin percentage or this percentage, that percent. I can only have one one such thing because if you say I want let's say State also here, you can add a state as a visual level filter, but if you now wanted to do let's say top end, you can only apply one top end filter. So you can't apply more than one top end filter. If you want that kind of stuff where you have more than one top end filter, then you have to go ahead and write down a top and major or you have to write down a rank and then you to filter it. So top end and the major filters are visual level filter properties. So visual level is something which only filters that particular visual. See anything I'm doing on this visual is not impacting any other visual. You might have seen the entire exercise which we have done; there's nothing changing in other visual. Now what we're going to do is let's go ahead and continue with this; these visuals will keep as is. So this is filtering on category; this is filtering on brand, and what we going to do is on the page level filter now. I'll go to the page level filter and let me bring in a brand on the page level filter. This is Page level filter, and I select Brand 1. Now there's no Brand 1 here; we don't know which whether in this category Brand 1 are appears or not; we definitely no brand appearance here, and their Valu should change. I click on Brand 1. Now the Brand 1 does does not appear in that particular set of categories, so it disappeared here; Brand 1. Why you're getting Brand 1 here? The reason is the moment I filter the page data, my top five got adjusted to that, and because I only selected Brand 1, I can get top five in that. When I add let's say Brand 11, Brand 12, Brand 13, Brand 10, Brand 2, I get a new top five based on my selection. So that's where the top end filter is working, and that's why we have brand still there, and you can see other places we have more values, and these values continue to change. Anything which you apply on the page level is going to filter all the content of the page. Now one of the limitations which the filters have, and that's where we are going to have slicer, that I I can't stop the filtering of this visual when I apply the page level filter. So either I do visual level filter which filters the visual or I filter all the visual; I cannot stop my filter to interact or stop the interaction between a filter of the page level or filter at the all page level which is below; I cannot stop its interaction with any of my visual which is available in my page. Now at the page level filter we have basic filtering and advanced filtering. In advanced filtering, because I selected multiple values, it's giving me this option, but I can erase it again based on what I select. I selected this on brand, so I can have contained, is not blank, is not blank, is empty, does not contain. So let's say do not start with b, and we don't have any brand which which is doesn't start with B; all the brands start with B, so we will not have any value. We'll do one thing; we'll remove this filter all together on the brand and let's bring in state from the geography at the page level filter, and here Advanced filtering is little bit interesting because then here we can say let's say start with n, New York, NE. You can say we got New York as the state level, and then there are few more State like New Jersey and New Mexico which start with new, so it's also possible that the categories are not having that kind of data, so they are not getting the values, so we are able to filter the values, so not. Now what I'm going to do is I'm going to erase these values and let's go to the all page level. What's the difference between this page level and all page level? So we understood that visual level is only at visual; page level is going to filter all the visuals on the page, but if I bring something at state level and let's say I select Alaska, it's filtered the everything in this one; go to other page, this page is also filtered; what this page, this page is also filtered; so everything is Alaska here. We said no, no, no; how do I make sure that it's only the multiple page level which filing? So we filter Arizona here, and then we go back to the filter pane page, and Arizona is filtered here. You say it may possible that the page level is filtering also on all the pages, not this one. So let's experiment; let's go to the page level filter again; this is filter on this page, and let's go to the basic filtering and let try to filter let's say Alaska and Arizona. Now this page is Alaska and Arizona, but if I go to this Azor map and you can still see all the values. Okay, you say very good, all the and you don't have a page level filter also here; you can you can see this; there is no page level filter; this all page level is all fine. Okay, let me go ahead and uncheck this and let's select Alaska. I select Alaska, come back to the filter pan, and I see only alasa value here. Remember we have two values selected, Alaska, Arizona, but the all page level filter is restricting it to Alaska, so we are only getting the value of Alaska and the cities of Alaska. In this manner, what is happening is basically we are able to filter at different levels: visual level, page level, and all page level. With this, now we will go ahead and learn slicers. Now slicers are at the page level, but there is a feature sync slicer which can make them available on multiple pages, so we have to learn that. We will now explore slicers. What I've done basically is I already created a page where I have taken the visuals from the older page, and when we was doing the filter pan, these are the same set of visual which were there. I removed visual level filter from the category uh pie chart, and I kept visual level filter as you can see top five brand on the table level, and I created a little bit of space here so that you know we can use the slicers. Now with we will use one property interaction here which I'm going to Deep dive into the details later, but we will be able to understand the slicer functionality better if we understand that how the slicer Behavior can be changed using interaction. To add the slicer, we have two slicer options, both available in Builder visual as well as homage insert. So we will open the homepage insert, and if we scroll down, we will be able to see both the the slices, the new slicer and the old slicer. As of now, we'll start with the old slicer, and then we are going to go to the new slicer also. If I enable the build visual region again, we have the new new slicer here, and we have the old slicer here.
They are not at this nearby place; they're a little bit far away. But you have the two of them here. The first thing which you want to do is we want to use this old slicer. And so if you click on empty space and click on the new slicer, you'll get it in empty. I would start by filtering the brand. So I can simply drag in a slicer, and then I can drag in a value field value here, and I can get a simple like this one. And this is basically categorical because of that the slicer has come like this, and I can actually select values like this. If I click on another value, it's going to remove the previous value and select the next value. Now if I want to select multiple, I can click with control. We can change this behavior with control. I can select multiple values; control again, control is present right now when I'm doing all these. So this is the first look. Now there are tons of formats available with this one also, and then we can create the hierarchical slicer also. So basically, let's look at the properties, and then we have to do multiple versions of this slice survey. So this is size and style and padding, which is very common; background we have seen; visual border and shadow, these are the things we are not bothered about. Title is something which, if you want, you can add it. Now brand already is available as a slicer header, which I can remove if I want.
Title. Now understand there is something known as slicer header; the moment I give it, it comes as a brand here, and then there is a set of properties for that. If I don't need it, I can create a title which is separate than the slicer, and the title can also be a function driven. Okay, so I can write down brand, and then I can get it based on a major, and then there's a conditional formatting also available. Let's say in this one I want to write down the set of selected values on the title, so I can do that. We will, once we learn a little bit more about the majors, we will be able to create that kind of a function which can give all the values on the title. Then we have the slicer setting. Now this is really important; this is something which we right now seeing; we call it as a vertical list. You have tiles; basically, the tile will be coming something like this, and that's why I kept a little bit space here and make it so you have the tiles here, and then if there are more values there would can be horizontal scale. We have the horizontal one. So this is style; previously this was known as orientation horizontal. This is style, and if I click here as usual, it's going to filter the values, and with control I can click on multiple values. So this was previously known as, and if you watched the last year video, this is known as orientation horizontal. Then we have a drop down; we can again adjust it. So drop down is something which you will not see the values as styles as well as the vertical; you will have a drop down, and when you open it you will be able to see the values. You can create a slicer in any of such ways. So let me do one thing; let me duplicate this one, and I'll change it to category. So instead of brand, let me go ahead and, and this is really good feature; you go to the arrow, and then you go ahead and change it; it gets changed. And this one we can, I'll keep it as a tile. Okay, so smaller value tile is a better option.
Let's look at the selection option. So we have a single select; means if you make it as a single select, single select here is not going to make any difference, but the only thing is even if I press with control, it's going to keep the single value. But if you go ahead and do a single select here, let's say on the this kind of visual which is drop down or tile, what would happen? So what we, let's do one thing, let's have one more here; make it a little bit small; let's adjust the brand here, and let me do one thing; let's create a little bit more space, deleting this visual; your brand, let's duplicate this; copy paste, and let's create a little bit bigger visual here, and this I'm going to bring in from other dimension. So let me bring in state here. I removed everything, and now I'm going to drag state, and definitely because the previous property it retained, it dropped down. I'm going to change it to vertical list. What happens when I make them single select? What is the difference? So here we don't see any difference because even if we click with control click, the only thing is selecting one value; the look and feel is having no difference when I go to drop down. So this is right now my drop down, and if I go to the selection and make it as single select on, you can see it becomes radio buttons; it becomes radio button, and there is only one value you can uh select. So if you want to select multiple and single select brand, then you can watch my video; single select with all that will help. Now what I'm going to do is I'm going to switch off the single select, and I'll go to the brand visual, and now here I'll make it as a single select as on. Once I make the single select on, you can see that this is how it looks like. So the vertical list and the drop down has similar kind of feature. We, I'm again going to make it as a toggle of the single select off, and these properties have changed over a period of time in last one year. So those of you are watching the older videos and maybe think it's a little bit different; yes, in 2023 we have a lot of these UI changes; a lot of renaming has happened with the new format pan with the on object interactions; the consolidation of the properties has happened in the different places, so that's why you will see all these things with a little bit different name, like we have this single select option. Now if I toggle this option, I will not be able to see multi select option and select all option.
These are few of the changes which we have got as part of the 2023. Before I tell you more about multi select, let me show you how to use select all. So I can enable the select all, and in this state visual you can see now I have the select all option, and once I click on the select all, I will get all the values selected. What I can also do is I can click on select all, and it will uncheck all the values. In the same manner, I can go to the brand slicer, and again there I will be enabling to select all. Once I enable the select all, it will be start showing me select all option inside the brand, and I can check and uncheck all the values using the select all. And how do I erase the values? So let me make it a little bit bigger. So if you are not using slicer header, then you will not get this erase option. See, if I want to erase, if I have slicer header, then I'll get it. So the disadvantage of not having this slicer header is that you will not get it. Title is not going to be a great option for us; header seems to be a better option because we got an eraser button. We know the title is not a better option, so I remove the title, and now I, if I select more than one values with control, and then I can erase it, so I can clear it off. So that's the advantage of having the slicer header. There is one option which we have not discussed, and that was multi select with control, and this is not visible completely, so I can make it a little bit larger so you can see this. So multi select with control is the property which, um, if I disable it, which is right now on, then what would happen is basically if I now select, I'm not, I have not pressed control, but still I'm able to do multiple selection. If I don't want to select anything, then I have to either press select all and unselect all, or when I selected multiple values, I can use the eraser button, come back and erase all the values. So same way you can have this multi select here; again we have to enable the slicer header if you need the eraser. So I enabled the slicer header, and then I can enable this one and I and disable the title. Now I can select multiple values without pressing control and use the eraser button to remove all the values. But otherwise, if you select, let's say if I selected these three values, now if I press control, I continue to select the same number of values. So I click again on that value to uncheck it. So in Power BI typically the selection is when you click first time it gets checked, and when you click on second time it gets unchecked. So in this manner you will be able to check uncheck values and had different kind of styles options on the slicer.
Now let's look at the other properties, like you have the border, background, padding, icons, all those things; you have adding icons and background and values. So now let's go to the values; let's check what options we have in the values by clicking on this state, so that everything is, we have a bold value, we have italic, we have underline. If you want those, we can change the color, but I do usually don't prefer it because I would prefer these things to change by theme. Uh, there's a border option, so you can have a border top, bottom, right. If you want, you know, values to have a border, then you can have it top; you want, you can on the top left; you want, you can have that; right, you want, you can have, or you can have all of them. Then you can choose the color for the border, and then you can have background. Right now there's no background, but I can go ahead and put a background if you need it, or we can simply give a white background, or we can say reset to default, so it will go back to the original value. Now this is what we had when we have one value. Let me go back and bring in the build a visual; we can have this slicer having more than one fields also. Let me bring in city; that's where we start calling it hierarchical slicer. So now you have the hierarchy, and you can open it, and you can see the multiple values. Now I can either select the complete state like this, or I can open like the California; I can open, and then I can select individual value from the California. So both is possible, and based on that it will work. Now remember we have checked the option select with control, so that is why the moment I'm clicking it is selecting multiple values, and this is useful when you have the related values, and you say okay, if I select state, I want to select all the cities. This gives you flexibility to have more than one into one slicer; instead of having dependent slicer, you can have this. So typically what happens is usually people say I want slicer one to filter slicer two; definitely if they are from the same dimension, slicer one does filter the slicer two. But in this case you have the values inside the the second one, so you have a better control over it. Let me show you that example where slicer one will filter the slicer two. So control C, control V; copy pasted it, and I'm going to remove state from this slicer, and let me go ahead here, check all, and let me click only on Alaska. So City slicer is getting filtered by the state slicer, which is city state, and I can remove City from here. Now you see only Alaska is selected, and Alaska does filter the cities which we have. Now Arizona is also giving Arizona City here. So slicer does filter each other when they belong from the same table. But if you want that I, I want one values inside another one like a hierarchy, then you can drag both of them into the one visual, and then you have that kind of a tap down selection which you can do, and you can select the complete state or you can select single cities, and pretty useful especially when you have the month, year, quarter, all those things; it is really useful.
Now what we have seen till now in the slices was only the categorical slicer. Let, now let me remove this city slicer, and let me make space for the date slicers. I go to the sales table; I bring in sales date here, and it created a table visual automatically. Let me click on the slicer; the moment I click on the slicer, because this is date is having the hierarchy, it created the hierarchical slicer for me, and as usual I can, you know, do those kind of selection which is month, year, quarter, and I can either select, let's say quarter Q1 2018; I don't have data; I have data in Q4 of 2018, so I can click there and can get some data. Now here we know date because right now it's getting hierarchy, and once we connect it with date table it will not get later on, but we have an option where instead of date hierarchy we can actually go ahead and say that we don't want to use the date hierarchy; we actually want to use the sales date itself. It created this list visual, but there are more options now. So I'll open the format now again, and let me close few of them, so it's still remain bigger. Now if I go to the slicer settings, you have vertical list, tile, but there are new options like between; can have date range between; we can have before; before this date. Now I have all the data before that, but what I can do here is basically I can go ahead and choose this data, and as you can see a little bit change in the data is there, there, and if I scroll the more, the lesser the values are coming. Similarly, I have the after slicer; we have the drop down; we, the very important thing which we have the date other than the drop down is relative date slicer. You can say last one day, month, year. Now my data is ending in 2020, so if even if I say one year, it's not going to come out, and it is always run based on today. So I let, I have to say use three years; in last 3 years I don't have anything; in last 3 years also; four years I have something; last 4 years from, and look at the date based on the date it calculated those last four years; the relative date. So relative, when you go to this relative slicer, when you drill down to the year, then there is an option relative year or the calendar year. So now when I say calendar year, you can see the complete 2019 is coming. When I said relative, it actually the rolling four years which has come. So in this manner you can use relative date slices also. So you have option for days, weeks, months, quarter, year, and all those. So definitely it can help you like when you say I need month, calendar rolling four months for the calendar, or let's say last 1 month. Now this is last one month, but you have option here next; the next one month, and then you have this; when you use this, there is a little bit different option from next because you don't have the calendar, and this one differently, this is the reality. So we only have the month or day. So this day, this week, this month, this quarter, this year. So you, you can use this, and this is one of the best options you can have in the date slicer. Remember one of the problem with the slicers that we cannot default it based on a function; means if you ask me can you default it on today, I can't do it; there's no option; actually can you default it on the first value; no, I don't have any option. You have seen the properties; we don't have any option. Let's go to the values; even we don't have an option here; we do have an anchor date option here; we, we don't have an option here also in the values where it can default using some major or a function. So relative date slicer can help it; you can initialize it on last one month, this month, last week, this day, this year; this is one way, and it will automatically keep on changing, and this is really helpful. But if you want to save it on Max month, on Max this and that, that's not good. So best way in case you wanted to save it on the this month, last month, this year, last year, calendar year or relative year, you have to use relative date slicer; that's going to give you that flexibility to save it. If you don't want to use it, then we have to create a column which is going to give us values like today, this month, next month, and using that we have to initialize, which we will learn a little bit later when we create the date table. So you have the slicers, you know the different kind of slicer, and also you know the challenges with default value and how relative date can help here. Now there, there are certain times when you will have challenges when you select certain value and the value is not there. Can you select the first value? No, it doesn't happen like that. So first value selection, last value selection, a little bit more dynamic default value selection for the slicer is not available as of now. We may see these kind of features very soon. For the number slicers, if you want to create a number slicer, you also will get a between and all those options. So let me quickly show you a number slicer, and so let me go here and and bring in, I have quantities which are only three in number and not getting okay, and let me create, make it as a slicer. So I go to build a visual; I make it slicer; I have only three values. It is by default created a between slicer, then I can have the less than quantity or equal to quantity, greater than quantity. So I can say quantity greater than one; I can say consider only those rows where quantity is greater than two; the values are changing. So we have between, before and after for this one. So number slicer, date range slicer, categorical slicer; same slicer going to work for all of them; you just need to change a few properties. We will now discuss the uh new slicer. So new slicer is available either in the insert menu under the slicer option or in the build visual; it is also available. I have enabled the build visual; now it was not uh enabled, so I enabled the build visual, and inside the build visual this is the slicer; new, new slicer which we are going to explore. Power BI has changed a lot over last one year; the new slicer has been renamed as tile slicer over the course of time. You can find it along with other new slices on the build window; you will see tile slicer, text slicer and the list slicer. Text slicer and list slicer are added a little later after this video has been recorded, but we will cover them a little later. So let me add a new page; let me close the reasons which are not needed, and in this visual first of all I'll add the new slicer. Now in the new slicer I'll need the column, so I can go to the add data; I can press the button add in the add data, and I can add, want to add brand, and the moment I add the brand it gives me buttons for the brands like this. Now by default it's giving me a 3X3 kind of a matrix; I can go, by clicking on the format, more options; I can play around with size, as you already played around; padding, border, visual border and shadow are common one; we can give a title if needed. So title is already available as a brand, and then we have the conditional formatting available for color and background. Title can be aligned; we can have a subtitle, divider and spacing; this is same for all those, and we go to the slicer setting; we have option for single select, select all option; you want to select all option, that is also available here. So those options are available; we'll see when we want to use the select all option, and in the shape we right now it's a rectangular shape, but we can have rounded rectangular shape like this. So they are now rounded rounded rectangles; then rounded corner; we can remove the little bit of rounding by making it less, or you can have custom style; means you will be able to decide how much the top corner should be like if I make top
Corner round, little bit. You can observe here, then this is top left corner. Then I can have top right corner. Now you can observe here, in this manner I can control, but actually I don't want to do individually, so I'll keep it like customize option off, and I'll keep rounded rectangle. And then we have the tab, both top; all those options are available; we can play around with that.
Now we go to the layout; this is important one, right? Why we are seeing this 3x3? Because we have three rows and three columns. The max number which you can give here is 10, so you can have 10 rows or you can have 10 columns. What I'm going to do is I'm going to say row is one; I'll have columns as 10. Now let me try, because I have 13 Brands, so can I give, let's say 15? You can't give 15. Let's try 11. You can't give 11. So you can maximum have 10. After 10, there would be a pagination for overflow, so you can have continuous scroll, means you can have a scroll or you can have the paginated. I will make it paginated. You want vertical, means this Arrow would be here. You can see there is an arrow here. I, when I went down, and if I went up, there's a down, so I can keep it horizontal because I'm keeping it like this. Then I can make it little bit smaller like this.
Now brand header, look; title looks little bit bigger, so we can make it little smaller. Now usually I don't change the font, as I told you in the past, but in this case I'm manually changing it, or maybe I'll just switch off the title; I don't need a title actually, so I'm, I have removed my title. So now these, this is my brand. Now what I can do is let's create a visual, and we can copy paste one visual from the other pages. So we go to the slicer page, and from there we copy this visual, ctrl C, come to this page, ctrl V. Now if I filter brand one, I'll get brand one. You can click on any of the brands.
Now let's go to the lier setting, and single select is by default on. I'm going to switch it off, and I'll also add show all. So now with the control click, I'm able to select multiple, and I can say select all also. I say select all, it is all selection is there, and in this visual we have lot of settings around, you know, H selection and all those. So when you go to the buttons here, way down, you have the default setting, you have the H setting, you have the Press setting, you the selected settings, so you have so many settings out here. We, we can do those settings. Then you have the call out value, Val. So call out values is by default default. I'll change the color so that you can know which what one, what is call; this is the call out value, the value which is in the middle is the call out value. I'll, and the best way to do is, and then I can make it middle align, so you can again see the difference here. Let me do the alignment little bit here, so that you are able to differentiate. Now pay attention, the small small adjustment are there. When I change the alignment, unit of display I'm keeping as whatever it is, and then show blank as hyphen, iph there is a blank value, and then there is a label option. I can switch it on, and I can add another column. Let's say I want to add category, so you can have little bit more information in these buttons; you can have additional values. So this is one option. Now we will remove this option label; right now we don't want a label, and I switch it off so that it doesn't take even a space.
Now the option which I want to explore is images. The default stage, over stage, selected stage, we can have different different places where we can do this. We can say add images field here. We can use a field for images. Now I need to build a field because I don't have, but what I've done for this is basically I have created few Mage which I've loaded to my GitHub account. I won't like to show you that first. So in my GitHub account I have this icon folder where I've created few icons, which is 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11. The these are just numbers, and I also created few images here. So I have brand images which is from B1 to B16, then I have category images which is 13, then I have few human images also which are faces we can use for customer. So I'm give you the link, and you will be able to use it. So what I'm going to do here is I will go to brand, and this is known as B1, B2, B3, so I can go to any one of these. You can copy this and replace the blob with the raw. Go here and you replace blob with the draw, and if you open the, you will still be able to see the image. I want to use this, but understand one thing, I want to make this little bit Dynamic, so I'll tell you how to create such a column. So I, I'll go back to my powerbi, and in powerbi I'll go to the table View, and inside the table view I click on the item table. The item table is already open. I'll click on that, and you have this option for new column under the table tool. When you click on the table you get the table tool, and inside that one you have an option new column. I'll click on the new column, and I'll call this column as brand URL. Now in the brand URL I'll give this URL, but it would be same; I want the after B the changes should happen, so I close my string at after B. Now I don't want this one coming from my image; I want it Dynamic, so between the two strings I can concatenate by them M perent, but from where I'll get 1, 2, 3, 4, 5, 6? I put 2 m%, and between the 2 m% I can again create one more, and I'll here I'll take brand ID. So what would happen with B, without space, brand ID, ment again concatenating the string, ment concatenate the strings, do PNG. Now let's see what we get. So we got a URL here, and this URL should work. Similarly I can create a category URL. We have category C1, C2, C3, and the folder name is also different there, but let me go ahead and add a new column, paste this, and let me call it category URL. I'll do some changes here. First of all this is not brand, this is category, and this is C. Same way I can develop a logic for human for customer. I only have 20 images, so you may have to develop some logic that you keep on using those 20 images. These cannot be brand ID here; I need to put category ID. So these are my two URLs. So now this is category C1, C2, C3, C4, and this is brand URL. Now for both these column what we have to do is click on the column in the data category; you have to call it as image URL. This is image URL. Okay, same way for category, click on category Ur, and into the column tools you should get column tools, and inside the column tools go ahead and change this data category to image UR. Both of them are now image Ur. Now let's go back to our visualization. We got the images inside the image field. I'll click on add data item, and I'll click on brand URL. Now you can see images here. Now we need to do a little bit of adjustment. I'll, I'll make, I made it little bit larger, but I can go ahead and decide the transparency, saturation, blur, position. Position could be left, position could be right, and we need a different kind of slicer for that, so this we will keep top or bottom only. Set as background, we can set it as a background. So this is setting for the default one. You can change the setting for the hover, pressed or selected; you can change those things settings, but I'll keep it default. What I would like to do now is I would like to add another slicer, so I'll add a new slicer here, and in this slicer, the new slicer, I'll make it little bit vertical after I add the column. So in this one I'm going to use add data; I'll go to item, and I'll add category. I have the categories. The settings which I want here is basically I'll go to the slicer settings, uh, I don't want single select; I want multiple select; I don't want show all option, and I'll let you know why I don't want the show all option. I go to the shapes; I would like it little bit rounded, so rounded rectangles, and I'll, I'll reduce it to it's say 15. I don't want to round it one also; no custom option layout. I'll go in here; I'll say five rows, and I don't want too many columns; I only want one column. Space between the card I'm going to reduce little bit, then overflow is continuous scroll; no, I want pagination, and vertical pagination or horizontal; let's keep it horizontal. So right now we don't have any kind of overflow, so we can keep it scroll also; continuous scroll, there's no need; basically we have given the five. Now we'll go to the call out values; we'll keep call out values as is as of now. Let's go down, and in label, if you want the label we can enable, but label, what happens, you can add additional field which we don't want here; we don't want subcategory or something like that. I'll go to images, and here I want to add an image, so I'll use add data, and inside the data I'll go to item, and I'll use category. Now I got the categories here. This is first category; why it is first C? We actually need a major, but we are using a column, so we can only use First. I'll do a little bit of adjustment, and now what could happen basically here is actually might not need values like category 1, 2, 3, 4, 5 in your organization; it might be possible, but looking at the color of the brand or let's looking at the logo you are able to decide, and that is the use case I want here. So I actually want to switch off the values. Now there are only icon; this is category 1, this is Category 2, Category 3, this is category 4, Category 5; this is what I want. So I, with the logo itself, I'm able to to decide. I'll go down the button properties.
Now let's look at button properties; fault, H, pressed and selected values, we can do different different settings, right? I, I'll keep it on default. Padding, you want white padding, narrow padding; we can use narrow paddings. Border, I don't like, but border on this button at least I don't want a border, so I'll remove border. These images are good enough. We come to Shadow; let's have a little bit of Shadow here, but the challenge with the shadow, if you want to have Shadow here, it takes a lot of space, and then you have outside or inside Shadow, based on that it is going to give you the shadow. So while the option is pretty good, but because I need a lot of space, I'm not going to use the shadow option. Glow is another, the Shadow and glow options are something which actually require a little bit of space, and then you need to go ahead and you know choose the colors and all those. So for that, outside and inside is the option. Center bottom, center right, top right, and all those options are there for the glow. Disable that. As ENT bar is one option where you will have a bar in front of it, so every line you can see there's a bar. This bar, if you need, then you can enable the ascent bar, which, which also I don't need, and let me say reset to default. So I, I have reset it to default. The only thing which I don't need is the Border. In this manner, now you can see that we have a different visual experience here; we don't have even names, and in this case we have the names, and the selection is highlighting. You might have, this is actually multiple select; we have to check and uncheck; we can have select all; it's all selected, and deselect all, and in this case you can only see a boundary, basically very. So when you use these kind of stuff, maybe we would like to change more properties when it is selected. So what you can do is here it is default; when it is pressed, do you want to do something? Okay, so want to increase the transparency or you saturation something; you want to do when it is press. So let me increase the transparency and press. Now let me go ahead and press it, then when it is selected, so I'll go ahead and say saturation is less, and then transparency is more; saturation is less. These are the seating in this press. So now when it is pressed, it looks little bit different. So these kind of stuff can help you. Now when I'm selecting, you can see the difference. So these things, especially when you are only dealing with the image, you need that, because, so when it is text, you will be able to identify because of the text highlighting, but you need it when it is only image; you need some kind of change in the Highlight as well as the saturation, so that you can identify that there is a difference when we are selecting or pressing it. So this new slicer allowing you to give a visual appealing experience, and as you can see we can use images to make it be more intuitive.
Let us now discuss the newly released feature of tech slicer. Tech X slicer was released in November 2024, so let's jump onto the release notes. This is the powerbi November 2024 feature summary, and then we scroll little down, you will find inside the content we have a new visual; the visual is texer, and it came as a perview. Now let me click on that, and we'll reach to the notes. These are the notes of the new visual; the text slicer, introducing the new text slicer now available in our core visual Gallery. This oneth brings the arrival of the new text Slicer in powerbi, offering new possibilities for both users and organization. How to enable: You have to go to the options and setting options, preview features, and text slicer visual; you have to enable it using that. I'm going to Showcase you that setting. The Tex slicer works by allowing user to input specific text that act as a filter targeting a design data feed. By entering the design text into the slicer input box, the slicer effectively Narrows down the data set to display only relevant information that contains the enter text. The functionality is particularly helpful for handling large data set where quick and precise filtering is essential for Effective data analysis and presentation. Now how to create: You will get this new text slice, and you can drag it to the canvas to filter the data set. Add a field from the data model to the, to the Field Val to establish the text slicer functionality, allowing it to filter the data set based on the user input. Simply add text to the slicer input box, select apply icon or press enter; the slicer immediately filters the data had displaying the visual results. The new text slicer introduced powerful customization filtering tool for powerbi, improved user experience and unmatch customization.
So let's jump onto the powerbi to explore this feature out. I'm here on the powerbi, and before I explore that feature of text slicer, let me showcase you how to enable this feature. Go to file, options and setting options; it will open a popup. Inside the preview feature, when you scroll down, you will see new text slicer visual feature; you have to enable that. Click on okay. If you're enabling it for first time, as I already enabled, I'm going to click on cancel. You might have to open a new file or close and open the file to get this slicer inside your visualization. I'm back onto the powerbi report View, and let me add a page to use this visual, so let me click on the plus button, and here what I'm going to do is first of all let me create a, a visual; want to create a table visual, brand wise net, brand wise net; let me converted into a table visual. Now I would like to add the text slicer here. In the text lizer, let me add the brand from the item into the fields by bringing the into the fields here. Let me type one and press enter, and as you can see all the branch that contains one has been filtered. I clicked inside, and I'm now entering 11, and let me press enter. Now I am getting data only for Brand 11 or everything which contains 11. Again go back, and let's say WR 10, and let me click on this Arrow which is apply button. I'm getting everything which contains 10, and in this case it is only brand 10. And we use nine and arrow apply; I got brand n. Same way I can filter other things. On the three dots you have the options like export data, show as table, Spotlight, sorted sending descending, and format; you have a clear button to clear the selection; you will get all the values. Now I would like to create a dependent slicer on this text slicer, which will get filtered, and based on that slicer I'm going to filter the table visual ual or other visuals. Let me add one more slicer; let me add brand to the slicer and make it as a list slicer. If I go ahead and try to filter one in the text slicer, it will filter both cable visual as well as the brand list slicer, but I only want it to filter the brand list slicer, and based on that I want to filter the table visual. For that we have to use edit interaction and feature, or click on the any of the visuals and go to format, enable edit interaction. This case we have to disable brand text slicers interaction with all other visuals other than the brand list Slicer. In this case there are only two, but let me add few more so that you understand it better. Let me control C, control V; I create two visuals. Now this visual is filtering; let me Al so change this visual to category. Let me disable B text slicers interaction with this new visual also. Brand Tex slicer as of now is only interacting with the brand list slicer, and it is not interacting with any other visual on the page as of now. So let me start playing around with this; let me end two. The TX slicer as of now is only filtering the brand list slicer, and when I filter the value in the brand list slicer, it is going to filter the other visuals. In this manner I am able to create a dependency of a search on a slicer, and then I'm able to use that particular slicer which is filtered by the search to filter my other visuals. In this manner I able to create a search experience along with the list experience. Let me enter a value one and click on apply, and once I do that I will only be seeing value which contains one in my brand values, and using those values, let's say I can select brand 10 and 11, and that will filter my visualization. So what is happening here is I am able to create of dependent slicer on my text slicer, and then I'm able to use that dependent slicer to filter my values of all other visuals. TX slicer as of now support only one f, means either I can have brand or I can, let's say drag category, and once I drag category it will only filter category; it cannot filter brand and category together. So I can have one at a time. In the past, on the similar situation when I use the text filter which is a very similar slicer to the text slicer, we have concatenated the values of all the columns of a table into one column, and then we have used that particular column to fill filter the values. I'll go to the table view; I go to the item table, and here I'll create a new column. Click on any of the column, and you will get the column tools, and inside the column tools click on new column. Once you click on the new column, in this new column we can append multiple Columns of the item table into one column, and then we can use that for filter. So let's create an column, appended column, and here we can have brand m% is m% category m% is m per a. Now we got a combined string. I could have added all the columns, but right now just for Simplicity I added only few columns. Now let's go back, and inside this text slicer, instead of brand, let's add that appended column, and let me do one thing.
Now, let me enable the interaction. This visual, let me start filtering out now. As you can see with the category one, what it is all fitting, I have added this new column, a pend column. Here and now what I've also done is I have enabled the filtering on both the visuals, and I'm going to remove this visual now. I don't need this additional for understanding of this, so let me remove this.
Now, let me start filtering. Let's say I enter a value, let's say 10. When I enter 10, I see both brand 10 as well as brand 2. I'm seeing brand two because 10 can be anywhere; it can be in brand, it can be in item. So, in this case, it is coming because of item. We can add a new visual on item name, and we can see that these are the items which are getting filtered because of 10. It may be anywhere in the string, broad category or name, anywhere in this manner. You can work on multiple columns, but that's still a workaround. Hopefully, I get supported with multiple columns; we will be able to use that. So this is all about the new text pre. Why don't you go ahead and try that out?
Now we will discuss about the list slicer. The list slicer was released in October 2024. So first of all, let's have a look at the release notes of October 2024. So I'm here on October 2024 release notes, and if I scroll a little down, I can see one of the features is new list slicer, and this is under preview. So let's click on that, and we'll reach to the feature. So first of all, we have to enable it. So to enable it, go to options and setting, option preview feature, and list slicer visual; we have to enable it.
Let's look at the release notes. Major enhancements are upcoming in the image support, label, additional conditional formatting option, and improve default style specifically designed for vertical layouts. Please note, new visual is in the early development, and we won't recommend using it in the production permanently. However, this is an excellent opportunity to experience the capability of this new slicer; provide us the feedback for the further improvement. So it is still in the preview feature. The new list slicer can become vertical when more than one field is driven into the field data. Well, this action will activate additional formatting settings specific to vertical data. Some of the advanced new slicer level customization offerings are selection shape, layout, overflow, style, selection icon, expand, collapse icon, and button style. These are the few attributes which has been released with the new list slicer.
So why don't we go ahead and explore it out, and for that I'm going to use N2 N12 file. So I'm here on the N2 N12 file, and I'm going to add a new page to explore this visual. So the new slicer I have already added, but let me tell you how I added it. Go to file, options and setting, options. Options and setting popup has now opened up. Inside that, preview features, and inside the preview feature, you have to enable the list slicer, and then you can click on okay so that you can use it. Some of the features require restart, so you might have to close and open your file again. As I've already added, I'm pressing on cancel. So I'm back on my layout. Let me add the list slicer. It looks like very similar to the normal slicer. So let me drag item R, and you can see there is a single select list which has been created here.
Now, let me do one thing before I go ahead and add certain additional stuff. Let me enable the format for it. In case you are not able to see the format option on the right-hand side, to enable the format page, you can get it from the view, view format, and then on the right-hand side you have another format option. Once you click that, you should be able to see the format page. Once you see the format pen, you can start working on the properties if you're visually selected. So we know the size and style; very simple based on your location and the size they can change. Then we have the padding. Padding, uh, right now I would like to keep as is; I don't want to change it. Background, in case we want it to have a background color, we can change it, and if you change the color, we need to make it a little less transparent so that we can see it, but right now I don't need any background color, so I'm going to disable it. Visual border, in case you need a border, and if you want to have the border, you need to increase the light and come out of the visual. There you can see the visual border. Again, I don't need visual border, so I'm disabling it. In case you need shadow for the visual, you can enable it. You can observe the shadow below the visual, and then for the shadow we have various options like outside and outside where bottom right, bottom, bottom left, right, etc. Again, I don't need shadow as of now, so I'm going to disable it. Title, we already have a title as brand, but we can use a major in the title. We can have different headings like heading 2, 3, 4 on normal. Right now, I keep it as is. We can have font color, we can have font name, size, bold, italic, underline, and the text color for the title. We can also have a background color for the title, and the alignment; we can keep it, let's say, central align or the right align or left align. Text wrap, in case there is a bigger title, it should wrap. Every visual now can have a subtitle, so we can have a subtitle if needed. If we enable it, we'll get additional space for subtitle. Then we can have a divider between the visual and the title, subtitle. Right now, I'm going to disable that also. Spacing, customize spacing. If you want to customize the spacing between the titter and the divider, but right now I don't want to change it. I can even reduce it further to save some space.
Now comes the important slicer setting. It is a single select slicer. You can see the radio buttons. I can make it multi-select by unchecking the single select, and now I can select more than one. Now, importantly, this visual has a show all. So you will say that is there with the slicer when we have the multi-select, but even if I enable the single select, I have the select all. Is this property only specific to this one or added to normal slicer? Let's check that out right away. Let's bring in the additional slicer, the normal slicer, put brand inside it, and let us see is that property also changed for this visual. We go here to the slicer setting, and we use select all, and then we enable single select. So you can see in the single select we don't see select all in the normal slicer, but in the list slicer we have single select along with the select all. So let me remove this normal slicer or the old slicer, and we can now enjoy select all. But does it work? Work to check that out. Let me create a visual brand wise net major. Now let me do select all. Everything is working. Let me deselect all: brand one, brand 10, brand 11, brand 12. One more thing which you might have noticed: if I do select all, and if I uncheck brand one, only one is getting unselected. So we have one deselection feature also here. So these are some of the properties. So let's go back to the format pan again of this slicer. We are on the slicer settings, so we have played around with that. Now we are very happy with the select all option also. Then here the shape: rectangle shape, rounded rectangle, snip, uh, snip tab, both these are the shapes which are available. So I'm going to leave them as is; I'm not want to check, but I would like to go to the layout. Layout is fixed. Number of button is on, number of button sh is it, and I can uncheck that. It creates a little compact UI space between the button. If you want to increase the button space between the button, you can do that, but I think right now it is fine. Indentation. Now reverse indentation. Now this will play a little better role when we have more than one intend the butter container. That also will play a little better role when we have more than one, when we create the vertical slicer. Call out values, the values which we have. If you disable the call out value, you not see anything. We need to have the call out value. It means these are the colors for the values like brand one, brand 10. So font size, bold, italic, underline, color, transparency, alignment, like we can make them right align, center align, left align. All these properties are display unit is Auto, and show values as blink, and then we have the layout, vertical alignments also there. Then we have a selection icon which we can enable or disable. Definitely, we need the selection icon. What happens if we don't have selection icon? I click, click on brand 11, brand 11 selected, brand 12, but I'm not able to see. So better to have a selection icon. Then I have buttons. This is also little important because the buttons are not visible unless you start grading a bot. Once you have bot, you can see the, you know, buttons. Then you can have fill or don't fill. You can have a shadow, you can have blow, you can have ascent bar on the buttons. So with this property you can create a button land of a UI, but definitely if you want to make it as a button, then you need little more space for each one of them. So if I want to, let's say, have shadow, now you can see if I made give it little more space then I can have the shadow, or you reduce the number of buttons, then you can also have these things. So I will disable that, but these are the various properties you can play around.
Now let's take the next step by bringing in one more field to the slicer, and let me bring in category. Once I bring in category, you can see that I can open the arrow; there will be nothing on the select on, but for each brand I can have next level, and I can do the. Right now it is single select; we can switch off the single select to make it multi-select. That's one more change which has came in last one year, where if you uncheck the single select, it becomes multi-select. So in this manner you have these properties, and now you can play around the little more properties here on the layout and on the icon. So especially expand icon. Now if I go here and play around expand icon, I can go to the layout, look at where is expand icon. Right now it is on left. Look at that arrow. Now it is going to WR. Look at the icon here. Same way alignment, we can play around this and the spacing, all these things we can play around with this list license. Some important properties have come in, and Power BI is paying a lot of attention to the visual property. So here what we are going to get is basically a new visual experience which with lot of properties which we can play around and make it suitable for our use case.
Now we have quite a few kind of slicer. We have a normal slicer, the we have the list slicer, which is previously known as the new slicer or the button slicer, then we have text slicer, and we also have the list slicer. So why don't you go ahead and try the list slicer out? We have learned slicers, and we saw slicer apply on a page, but in case of filter we do had an option where it can work on all the pages, and we have something very similar. Sync slicer is a process in which we can sync a slicer on one page with a slicer on another page. Now usually, we sync the slicer which is having the same name or the same table on the other page. A little bit later I'll also show you a way where you can sync the slicer which do not belong to one table, means the slicers are coming from two different tables, and they can have two different names also, but they are of same type, like City. So let me add this page, and here there are certain slicers which are applied, and I have this visual. Copy this visual, need page two. So can I, can I get the category slicer? Can I go ahead have a category slicer, and if I filter something here, can it do filter there? On this, first of all, this is a single select kind of a slicer. Can I do that? There's something known as sync slicer. There would be limitations. What is happening on that? Select category two, and if I go to this page, is it going to be category? So there are a couple of ways to achieve sync slicer. I'm going to tell you both of them. So one of the ways is from menu options where you go to the the menu and use the View tab, and there you have the sync slicer option that you can use, and the second option is when you copy paste the slicer, you do get an option to sync. You have to click that option to sync, and then it will get synced automatically. So let's start with the first option, and then there is a known as we have insert, and in the insert we have, we have View, and inside View we have sync slicer. So if I select this slicer, it is telling me that I can sync it in the slicer and the page two. We have View, and inside View we have sync slicer. So if I select this slicer, it is telling me that I can sync it in the slicer and the page two. Let me do that. So one option is sync, and second is visible. I've done that. Now I go back to the Category 3, category 4. I come back on the page two; I see only category 4. Enlarge it. The slicers are getting other way. And easier way to do this thing, slicer is copy it, Ctrl C and Ctrl V. It asked for sync slicer, you, I want. Now you can see that I select brand one, I go here, it is, I'm able to sync the slicer pages. This is sync. This is the old slicer, and the copy paste or using the sync slicer paint which is available in the View, we can do that. But can we do it on the model new slicer? Where is our new slicer? Our new slicer, and I do the same. Let me Ctrl C, go to the page, Ctrl V. Is asking for slicer, brand 10. I filter a brand 10 here. I go to the other slicer; it should show brand 10 because they belong to the same table. If I go to the new slicer page, is also brand 10. So both the old slicer and the new slicer can be you think either by copy paste or using View sync slicer. Only thing you have to do is click on a slicer know where it should be visible. So in this manner, can sync the slicer, and then they can filter the data across the pages.
So now we would like to discuss a use case which is sync slicer across different fields, and these different fields could be across two different tables, columns. So typically the sync slicer is for the same field. So let's say if I have geography City on page one, I have a geography City on page two, I want to sync them, but this case is a little different. I want to sync the slicer which is across two tables. Let's say customer City and geography City. I want to sync them. They may not have even name a city; they could be little different name. So we want to sync slicer across two different fields. That's what the main objective is for this one. What has happened that I have used a little different file. That's a very common file which I use for abstract thesis series, the file at GitHub which you can also get from my GitHub account. The file follows the same model which we are following in the learn Power BI series. You will be able to relate with the fields which I'm using in this art of the video also. So how can we do that? So to do that, let's try that out on Power BI file. So let me open my Power BI file. So I'm here in my Power BI file, and I'm using the generic model which I'm using in most of my other videos. So here I'm using my common sales model which I'm using for most of my videos, and this model contains a sales table join with the date, item, customer and geography table, one to many, single directional join from Dimension to fact. The same model we are going to continue here, and here what we wanted to try out is is basically I would like to add, let's say from the customer Dimension I have a city, and let me convert this into a slicer. I have a customer slicer City, and I also would like to add a slicer from geography table which is City. Let me change this also to a slices. So I have two slices which are basically on City on different one, one is on geography City, another one is on customer City. So if I select one of them, as you can see, there is no impact on each other, but if I go down and add, let's say some Visual, and in that visual I'll take data from item, brand, and and take a measure like net. Now if I select something, let's say I select one of the city from here, you can see the data is changing. If I select another one from here, you can see changes. I select from both of them may not get any data because mostly these cities are kind of similar kind of City, whether this is this page or let's say if I even duplicate this page, they are on this page. I would like to have sync slicer. So I want to sync the slicer either on within the page or across the pages. So how do I do that? Because if I select a value, there is no way I can, you know, think with this, and if I go to, let's say, View, and if I, I go to sync slicers, as you can see, I have do have option where I can sync it with other page, but I don't seems to have an option where I can sync these different one with this. As you can see, I can see the slicer here. There are two slicers which I can see across different pages which is visible, this one, city, customer city. As you can see, it is highlighting that customer city is available in those pages, and I can sync them by clicking on the value. So if I do this, if I sync it across the pages, if I clicked on, let's say, Atlanta here, and if I go to the duplicate page, you can see that Atlanta values, but how do I sync these two slicers on the same page which are from different dimensions? Let's look at the details of the sync slicers again. In the sync slicer, what I'm going to do here is I'm going to go to the Advance option. I've unchecked the syncing right now. I go to the advance. So let me give it as a name, City Dy. So I've given it as a name, cDy, and let me come to this slicer and also give it as a name, cDy. Now this is cDy, and this is also cDy. Let me select one of these. Now you can see whatever values I'm selecting is also getting selected on the other slicer. So now you can see that whatever value I'm selecting here on the first slicer is also getting selected on the second slicer. So there, from different dimensions, but I able to sync them. Now can I sync them across the page? So what for that what we have to do is, let's say this is the slicer here, I go and here I. So if I give the name as tore Dy, it will also get sync. So let's say if I select a value here, check this value. Let me select a value, Austin here, go back to the first page, you can see all these three slicers are now showing the Austin value. So I'm able to sync across page which I was able to do previously, but across different dimension table or across different table columns, I'm able to sync using sync slicer. So the property is lying in the advance. Once you rename and give them a common name, that is where you have an opportunity that you can sync slicer across tables with columns coming from two different tables. So why don't you go ahead and try this out?
We will now try to create combo visuals. Combo visuals are the visuals where we have basically either bar and line together or stacked bar and line together. So couple of combo visuals are there, uh...
They can be found here in the build visuals region, or you can find them here now line visual. We have already seen the secondary axis. Now, the thing which you are going to get here is the secondary AIS, and I'm going to start with the cluster column chart. I bring in the cluster column chart, and here on the x-axis, let me bring in brand and on the y-axis, let me bring in net. Now, there is a line axis, line Y axis. Now, what I'm going to do first time, I'm going to bring in Gross here, and you will find that there's a line y-axis, but I did not get in a secondary Y axis. If you see both of them get adjust yis, there's no secondary y-axis. Now, this happens when you take the two variables which are having the similar kind of stuff; it automatically put them on the same one.
Now, what happens if you need the secondary AIS? I actually want it to have. So you go to the visual format, which is right now available here; otherwise, go and click on the three dots and format to get it, in case you are not getting it. Now you are not getting a secondary Y axis. We do see the property of the secondary Y axis here, and you go and enable the values. The moment you enable the values, they start showing the secondary y AIS. Now, because of the kind of values you have, there was no need of secondary y axis; it was not showing, but you can enable it. Let me disable it, and let me do one thing: instead of gross, let me try to bring in margin on the second line AIS. Now, the moment I bring in margin percentage, because I manually switched it off, it's not showing me, so I will switch it on and do. But usually what happens is basically when you have the majors which are not of the same kind of a range, it will show you the secondary y-axis automatically.
Now, what I'm going to do here is I'll going to play around with a few things and tell you what all you can do. Now, this is one thing which you can have. Similarly, you can even have a legend, and along with the legend also it will work, but Legend do not work for the line. So if you want multiple lines, you need to have multiple measures. So like I have, I have margin on the line axis; I can have discount, but the legend is not going to work if you're looking for a legend, then it's not going to work on the secondary y AIS. It is true across line chart, line clustered column chart, and line tagged column chart; it's true across that. So I'm going to remove it again. Same thing, we have one more thing which we have done in the past: instead of having it as a legend, we can have it as a second AIS, more than one, and both of them in the expanded manner; then also we can have it, but again we have the lines based on the majors; we know we can't use legend for that.
Now you have the lines; you then again you can use different kind of formattings. What we are going to do here is first of all, um, we will go to the below, and there is a section for columns where we can do the formatting for the columns, and then there is a section for the line where we can do the formatting for the line. Now, because we are using only one x-axis, or we are not using any Legend, there is only one major; we get the FX option, so that is again the what you are showing on the primary AIS. Even if you're showing the line on the primary AIS, still, if ideally there is this column contains one, there's no Legend, then you will be able to get the FX option, means you can do conditional formatting. Now, if you want border, we can have the Border here. I like to increase little bit transparency; this is too darker, so I actually wanted to increase a little bit transparency to look, look and match the column color is something which I want to use. I also want to increase the Border width so that it is little bit wider. So these are some of the things we have done in the others also, and then if required you can increase the space between categories so that they are little thinner bar. You can use reset to default for a particular category to make it. Now, series is we are talking about margin all or discount, so if all what are the options you have is you can decide for both the lines whether you want solid or dotted.
Now here I'm going to CH show you this line smooth and sted. So now I'm going to make it smooth. You see this is the smooth line, and this is the property I've not shown you in the line visual because we had too many values there. Then you have the sted layout, which is basically the step one. So let's do one thing: uh, instead of all the series, let's go to the margin percentage. We have the margin percentage as the smooth line, so we have one smooth line, and when we have a stepped line. Now, width right now is three, but I'm going to do one thing: I'm going to go to markers, enable it. Now both the lines are markers. What I'm going to do here is I go to the margin percentage and let me see, do I need disable? No, I need margin; I need marker for margin percentage; I don't need marker for the one the step layout, so I removed the marker for the discount percentage, so there is no marker for the discount percentage. Let me change it to margin percentage; I keep the marker, and I can have different kind of marker. Let me take a different kind of marker this time, make it little bit bigger; color I am fine with whatever color it has, but what I'm going to do here is I will go up, and right now already in the series I have margin percentage; I go to the line and I make St as zero; all the value is there.
Now what we can do here is basically when we go to the data label and enable it. Now we have enabled for everything. Now one thing is that only for this dot, this values is coming; this percentage value is only for this dot. You see carefully that for this dot the values is coming. I can completely remove the marker also and keep the values also; sometime we do that kind of hiding off line and just keeping the value. Let's say I'm showing net, and I want to show the value of gross, and I put a line of gross, and then I just keep the values of gross and don't show anything on, but I can see the de values and all the data level properties like title value. This is basically major driven; so basically what I happening, these labels are major driven labels. Now everything which you want to do, you can have a major me for title; you can have measure for Value; you can have measure for details; so three things you can have, like not everywhere I want to have titles. So what I can do here is basically when I go to data label, I can for the margin percentage I wanted to have a title also. For margin percentage I have title in the single line; right now it is there. If you remember the property we have here is when we go below in the layout, we can decide whether it's a single line or multi-line. I can make it multi-line. Uh, now I'm as of now I'm only doing it for Discount; I can do it for all of them. In this manner we can do those changes. So this is our bar and line; let me call it with the simpler name, and let me duplicate this. Same way what I can do is I can click on this and convert it into staged bar and line. Now when I convert it, you will might see only small difference; nothing much has changed, but the things will change the moment I bring in category here. Once I bring in the legend, now you can see the Legends also here, and then as usual on the column values you have this thought order reversal, and you can have the space between the serieses. Now for line we have markers and everything, so you can play around with the data label if you want, and then we have the series label. When we go down, we have the CDs discount and margin; the labels are shown here. Basically, if I enable it, now you can decide for each series what you want; the position on right or left you want, and the value and the series color whatever you want, and word r if the series name is pretty long, you can have that you want to have background. So I enabled the background, but both the series color and the background color uh need to be a little bit different, so let me change the background color to different. You can see transparency; I can increase total labels again because it's a stagged visual, so you can have the total label, but it will look too busy if I have that, and then we have the error bar options and where you can use various stuff.
In this manner, um, I have this tagged and line visual, as you can see that with the new major driven labels and with the help from the data label enhancement and the enhancement which has been done for the bar WID for the transparency and the Sorting of the bar, we got a new era in the visualization of the tagged Visual and the clustered column bar visual to take them to the next level. And as you can see, those of you have watched the series in the last year, you will see a lot of difference in terms of what we are creating here versus what we have created last year. Visual level format sting has been released in August 2024, and now we are going to discuss those. This part of the video I'm using a little different file, not the same file which we are using for learn power ba series; I'm using the abstract thesis data file, but I'm using the same model, so you will be able to relate with what I doing using the same fields which are available in your learn powerbi files which I have shared with you on the GitHub. So let me quickly jump onto the August 2024 notes, and in August 2024 notes, if you scroll a little bit down, you get this new feature which is visual level format things. Now you might be knowing that visual level and calculations have came few days back, and you would like to format those strings, and there was this challenge how do we format; how this option has came, and there are various things which has been supported now. So it is not only supporting at the visual level, but it has been done in a manner that you can do it at the model level, visual level, and and the element level.
Let's understand this feature. First of all, let me click on that SC down for visual level format strings. Let's understand this feature. Visual level format things are here providing you with the more options configure matting and configure the formatting originally bu for visual calculation. This has been actually bu for the visual calculation; the core ability that the visual level format strings provide is the ability to format visual calculation. Basically, it allows you to format the visual calculation, which is basically when you create these new visual calculation or visual level calculation or me visual calculation are not in the water; you cannot format them unless you are using them in data labels or a specific part of the card and new slicer manual. Basically, what happens is because we were formatting our measures at the model level, and then if you want to format them further, we were formatting them in the data labels and few places in the card which were nicer; other than that we were not able to format, and if you want to format your visual calculation, that's the option we were using. Now we would like to go beyond that, and we would like to them at the visual level. With visual level formatting string you can do that, so means you will be able to format the visual calculations. For visual level format string, however, are useful even without visual without visual calculation; they are also useful. What are the three levels? Now we can do it model level. We format this model level; you can set the format for columns and measures in the model; anywhere you can use that column or measure, the formatting of the apply unless overwritten by a visual calculation. Element level form; what is the visual level? Then this is what is introducing here or introduced today with with this release notes; you can set the format of the string any column or a major or a visual calculation that is on your visual; even they already had a format string, in cases the model level format string were written, visual level format string would be used because this visual level will have higher priority over the model level.
Now next come the element level. You can set the format for data labels and specific elements of the new card and new slicer visual. This will be pended including much more in the future. Any format string you set here will override the format string on the visual add the model. So now you will explain you element level selected element on a selected visual measures or column and visual calculation both; it applied visual selected visual applies to measor and columns and visual calculations. Model: it applies to all the pages and the reports on the same model, and which one will impact it has been given here. So first is model level; if you have the visual level, the visual level will apply; if you have the element level, then the element level settings will apply; it has been explained from where you can get the model level. So model L you can set from the major tool or the column tool, or you have these properties under the modeling from where you can apply the model level setting. For visual level you can find it under the data format once you open and select the visual. When you further go down, let's say you want to set up the data label inside the data label; further you can go ahead and change the formatting of your measure using the format strings. So this example is been given. Now the total is shown as scientific notation, but only in the data label, not in other places such as tool tip as shown below. Notice how the element level formatting is used in the data label, but visual level model format thing is still used for the other elements in the same visual.
Now we have understood this feature detailed; time has come that we go to powerb desktop and explore this feature out. So let's move to the power ba desktop, and here I'm going to add a new page, and in this new page I'm going to add a table visual. In this table visual let me bring in BR; let me also bring in, and let me duplicate it a bar visual because not every property applies everywhere. In the bar visual let me go ahead and enable the data labels also. I'll open up the property Pane and I will enable now the data labels. As you can see, data is now displayed in millions, and this happens because of the data label properties. So go to data labels, go down, and then open values, and inside the values you will see the display format is Auto, and you can change it as per your requirement. So now let's go ahead and custom on look at the formatting of the major. This click on the major under the major tool; you will be able to see the formatting of the major. Right now the formatting is joural, and all other values are set to the default values. So let's start by by changing the format. So I can click on the format and start writing down my own format. So I would like to write down a format hash comma hash HH hash, and I'll not give any decimal place or zeros after that. Now if you see the other things were disabled, and if you look at my net menue here, now net has no decimal place; it has been formatted using the million format. Let's look at the bar Visual, and in the bar visual on the tool tip you will see it is following the model format. We have to now discuss the label format, but before that let's experiment with the properties of table visual. I can go to properties, and under which I can found data format. I don't want to set up for brand, but I would like to set up it for net, which is auto as of now following the model level formatting. I can click into the format and replace it with a million format of hash comma hhhh do0. So I will now get one decimal place; press enter to commit and now go back to the table visual where we have done this; you can see one decimal place is coming, which is the visual level format different from the model level.
Now to explore the additional properties, what we are going to do is we are going to go to the bar Visual and try to set up some visual level and elements level formatting. I go to the bar visual here, and in the bar visual I go to the property, and I have data format, and I want to give a data format. Now the format which I given for the table visual definitely not going to apply here; we will give the same format here hash comma Hash Hash has do0; it means one decimal cas. You will observe no difference in the data label, but when you go to the tool tip, you see it is one decimal place in the million format, and that is what we wanted. So now my visual is following the visual level format, but I'm missing a visual with a global format. So what I'm going to do here is I'm going to add one additional visual here, so let me add a bar visual here, and inside this bar visual I will go ahead and add net and brand from the item table, and now if you look at this visual you have the global format. Now we would like to go ahead and experiment with the element level formatting, so let me click on the first bar visual which I've created and go to the data labels. In the data label let's scroll down to the values, and inside the values we have display unit; you can select the display unit as null, and you will observe that now the labels are also following visual level format. In display unit you can also choose any other formats like thousands, million, billion, etc. You can prefer to choose Auto format; Auto is the one of the most common format we use, and once you are using Auto format, you can decide the number of decimal places; let's say you can change it to one or two. Now I would like to give a custom format; the moment I choose it, it shows me the visual level format. Let's start writing down now hash comma Hash Hash Hash the million format d0, and 0 means you have to show two decimal places. In place of 0 0, if I would have used Hash Hash, it means the digits are optional; it means if there is a one digit, it will show one digit, not two digit after the decimal. So let's look at this line where we have 7.0; if I would have used Hash Hash after the decimal, it would have only shown 7, not 70. dou 0 makes it compulsory to have two decimal places. We are now using three different formatting for this measure net, so if I click on this measure net, you will see at the model level we don't have any decimal places, and if you go to the tool tip of the second bar visual, you don't see any tool tip. On the table visual you see the visual level format with one decimal place; on the first bar visual you see on the data label the two decimal places, means the element level formatting, and in the tool tip you see the visual level formatting. Now we have explored the format string feature at Major level, visual level, and the element level, but the visual level format feature has came for the visual calculation, so let's go ahead and explore one visual calculation too. Let me add a visual calculation on the table visual; the calculation I want to add here is next next of the net; I want it; means it's going to give me the next row. Let me press enter, and it is giving me a calculation which is giving me Nest, but the formatting is not following any of the format which we have done at the model or the visual level. We need to change the format, and to change the format we'll go to the format pan, format pain properties, and inside this we will choose this calculation, and now here we can give a format what we want: hash comma Hash Hash has the million format.
And as you can see, the calculation is showing without any decimal place, but net is following its own format, which is basically having one decimal place. Now you have seen how to format a visual calculation at the visual level. We have now learned how to format at element level, visual level, and mod level. So why would you go ahead and try out visual level format strings?
Let's understand what is DAX. And what I'm going to do is I'm going to use the definitions which have been provided on the Microsoft Learn site, so that we are, you know, very near to what Microsoft has given. So DAX is Data Analysis Expressions, a formula expression language used in Analysis Services, Power BI, and Power Pivot in Excel. DAX formulas include functions, operators, and values to perform advanced calculations and queries on the data in related tables and columns in the tabular data model. So in all these Analysis Services, Power BI, Power Pivot, we use tabular data model. So in the table of data model, to create the formulas or the calculation, we use DAX, and this is what we are going to use now onwards a lot when we are going to learn the formulas, the columns, the calculated column, measures, tables, RLS, etc. DAX is used in DAX calculations. DAX formulas are used in measures, calculated column, calculated tables, visual calculations, and Row Level Security. These are the places where DAX calculations are used.
So first of all, what is DAX measure? Measures are dynamic calculation formulas where the result changes depending on the context. Means if your filter context is changing, then the results will change. Measures are used in reporting that support combining, filtering model data by using multiple attributes, such as Power BI report or Excel pivot table or pivot chart. Measures are created by using the DAX formula bar in the model designers, and we'll go to the Power BI Desktop. This is where we are going to learn the DAX measures. We have the option to create the measures; we have it under the Home tab. We will also get it into the table tools, that's calculated column. The calculated column is a column that you add to an existing table in the model designer and then create a DAX formula that defines that column's value. When a calculated column contains a valid DAX formula, the values are calculated for each row as soon as the formula is entered. The values are then stored in the in-memory data model. So basically, the DAX calculated columns will be calculated and will be stored in the model, while the measures are basically runtime, which is going to be executed when we actually use them onto the visualization.
Calculated tables. Calculated table is computed objects based on the formula expression DAX from all or part of the other tables in the same model. Instead of querying and loading the values into your new table column from a data source, a DAX formula defines the table's value. So basically, you are not getting it from the source; you are actually calculating it based on the other data which is coming from the source. So basically, it can be based on other table or time. We may create tables like calendar table, which is actually driven by completely by the formula only. Calculated table support relationship with other tables, means yes, you are calculating a table, but still it can have a relationship with other tables. Calculated tables are recalculated if any of the table it pulls data from are refreshed or updated. So if it is taking data from any table and that table's data get refreshed, it will also get refreshed and updated.
Visual calculation. The DAX visual calculation has been very decently added to Power BI. A visual calculation is a DAX calculation that is defined and executed directly on a visual. So it is only at the visual level, not beyond that. So the scope of visual calculation is visual. Visual calculations make it easier to create calculations that were previously hard to create, getting a simpler DAX, easier to maintain, and better performance. So the reason for giving this is basically you want to have a simpler DAX, like looking into previous, no, next row, first row, last row, or even creating the running sum; all these are going to be really easy if you use DAX visual calculations.
DAX queries. DAX queries can be created and run in the DAX query view of Power BI Desktop and open source tools like DAX Studio. Unlike the calculation formulas which can be only created in a tabular model, DAX query can also be run against Analysis Service multi-dimensional model. DAX queries are often easier to write and more efficient than the multi-dimensional data expression MDX queries. So those of you who have used the multi-dimensional models, you might know that the MDX query is used and it is real. Now DAX is easier. Again, the DAX query is basically we are trying to do what we are doing in the SQL, to write down the select query. Here we are writing down DAX queries. Now the DAX query, when you wanted to write down in DAX query view or DAX Studio, you need to make sure that it returns a table, and you can also use EVALUATE function to evaluate these queries, just like SELECT does the job for you in the SQL world, EVALUATE is going to do the job for you. So to run the DAX queries, you need to use EVALUATE. One should make sure that the query should return a table. So if it returns a table, then it's going to be displayed in the DAX query view or the DAX view. You can also use ORDER BY index queries, which we do not use in the visual explicitly, because what happens in the visual, we have an option to sort on a particular column, and we use that option to sort. We do not need to mention that, okay, order by this column; that has been taken care by the visual features.
Data type. What all data types does DAX support? You can import data into a model from many different data sources that might support different data types. When you import data into a model, the data is converted to one of the tabular model data types, and these are the data types it will be converted to: whole number, basically the number without a decimal place, so this is very similar to integers; decimal numbers; Boolean; text; date; date and time; valid dates are all dates after March 1, 1900. So if you have a date before that, then it might not work; currency; and a blank. These are the various data types which are supported on the DAX, and you, when you are going to use that, you will realize that these are sufficient for our calculations and, you know, working on the...
So DAX variable. You can create a variable within an expression using VAR. So you can create a variable. Variable is technically not a function; it's not a function; it is a keyword to store the results of an expression as a named variable. So basically, you are going to have an expression, and that expression will be saved as a variable; it will be given a name, and that name can be used further. That variable can be passed as an argument to another, as an argument to other major expression. For example, Major equals to VAR MaxState, and then you'll use the RETURN statement, and then you're going to use it again, like in this case we are using CALCULATE, SUM of say Gross Amount, FILTER ALL Date, Date of Date equals to MaxState. So I'm using the variable, and it is really important whenever you are using a variable, whether you are using in a measure or whether you are using it in a column, you need to use the RETURN statement. RETURN statement is only needed when you are using a variable. If you are not having a variable, you could have used simply, let's say, Major equals to SUM of Gross Amount; that will also work when you're using DAX variable. So you need to make sure when you are using DAX variables, you should use a RETURN statement to complete your measure or a calculator column.
So these are the various definitions I wanted you to know before we move into the depth of the DAX. Now we will now go ahead and discuss context. There are various kinds of context in DAX, and it is really important to understand that. Now, sometimes when we are using these contexts, we may use only the word context or a visual context or a row context. We'll also try to understand that. So let's understand the different kind of contexts which are available in Power BI or in DAX.
So what is context? Context is an important concept to understand when creating the DAX formula. Context enables you to perform dynamic analysis as the result of a formula change to reflect the current row or the cell selection and also any related data. Understanding context and using context efficiently are critical for building high-performing dynamic analysis and for troubleshooting the problems in the formula. So basically, context is applying everywhere, and we need to understand what are the different kind of context and which context is applying back formulas in the table or model. Formulas can be evaluated in different contexts depending on other design elements. What are those design elements? Filters applied in a pivot table or a report; filters defined within a formula; relationships specified by special functions using formulas. There are different types of contexts: row context, query context, and filter context.
Now let's understand row context. Row context can be thought as... row context can be thought of as the current row. If you create a formula in the calculated column, the row context for the formula is included; the value from all the columns in the current row. If the table is related to another table, the context is also included; all the values from other tables that are related to the current row. It is basically every row; it will get executed, and every row has a context; that is where the row context comes in place. For example, suppose you create a calculated column, Quantity 1 plus Quantity 2; let's add the values from two columns, Quantity 1 and Quantity 2, from the same table. This formula automatically gets only the value from the current row in the specified column. So it's only getting one row; it is not getting more than that. So that is where the row context is applied. The row context also follows any relationship that has been defined between the tables, including relationships defined with a calculated column by using DAX formulas to determine which row in the related tables are associated with the current row. RELATED function can fetch a related table based on the relation. So basically, you, you can say Quantity plus related tables quantity, so it is going to fetch row by row that values. So all these places is row context. So basically, your row itself is a filter of data; it is not going beyond that particular row's calculation. So it's not that if I say Quantity 1 plus Quantity 2, it going to sum up all the quantities in the table; that's not going to happen. We will take an example when it's going to happen, but that's not going to happen with the row context is in place.
So DAX is multiple row context. DAX includes functions that iterate calculations over a table. These functions can have multiple current rows, each with its own context. In a sense, these functions let you create the formula that performs operations recursively over an inner and outer loop. So basically, you are executing on more than one row. For example, suppose your model contains a product table and a sales table. A user might want to go through the entire sales table, which is full of transactions involving multiple products, and find the largest quantity order for each product for any one of these transactions. This is one example when you want to calculate multiple rows of the sales table against each product; that's where you are using multiple row contexts. With DAX, you can build a single formula that returns the correct value, and results are automatically updated at the time the user adds the data to a table. So the DAX will take care of the execution, and you will get the correct formula. So one of the examples using EARLIER is like I want to find out the first sales date when the customer came to me for the first time. So this is MINX, FILTER sales, customer ID equals to EARLIER customer ID. So it's going to look at for all the customers in that table and go to find out the minimum sales date. To summarize, the EARLIER function stores the row context from the operation that precedes the current operation. So basically, it's a multiple row context which is coming into play in this case.
So let's understand query context. Query context refers to the subset of the data that is implicitly retrieved from a formula. For example, when a user places a measure or the field into the report, the engine examines the row and the column headers, slicers, and report filters to determine the context. The necessary query then runs against the model data to get the correct subset of the data, makes calculations defined by the formula, and populates the values in the report. So basically, what happens when you create a visual? So it has, it might be getting slicers, it might be creating filters, it might have the columns, row columns, or column head, based on all those, a query context is formed, and then you get the result. So this is what the query context is. Because the context changes depending on where you place the formula, the result of the formula can also change. For example, suppose you create a formula that sums the value in the Gross Amount column of the sales table, let's say SUM of Gross Amount. If you use this in a calculated column within a sales table, the result of the formula will also be the same as the entire table, because the query context of the formula is always the entire data set of the sales table. The results will have Gross Amount for all regions, all products, all years, and so on. So if you use the SUM of Gross Sales Amount in a calculated column versus a measure, your expectation of the result should be different. In case of a measure, it is based on the query context of what is present in the visual, in column headers, row headers, or what is coming because of filters and slicers, but in case of the calculated column, it is going to take the complete sales table and go to calculate. However, users typically don't want to see the same results hundreds of times, but instead of, instead of wanting to get the profit of a particular year, a particular country, or a particular product, or a combination of these, to get the grand total. So this is what we want; we actually wanted to group the data. This is what we do in a Power BI visual; we wanted to have the grouping of the data based on a particular year, country, etc. In a report, the context is changed by filtering or adding or removing the fields and using the slicers. For each change, the query context in the measure is evaluated; therefore, the same formula used in a measure is evaluated in a different query context for each cell. So basically, your visual may have different sets of columns, different sets of filters and slicers, and based on that, it is going to be evaluated in different query contexts.
Let's come to now filter context. Filter context is a set of values allowed in each column or in the values retrieved from a related table. Filters can be applied to the column in the designer or presentation layer reports or pivot table. Filters can also be defined explicitly by filter expressions in the formula. So we have filters and slicers; we also have, you know, filter expressions in which we can use in CALCULATE or the expression function that also can give us the filter context. Filter context is added when you specify a filter. Filter context states on a set of values allowed in a column or a table using the arguments to the formula. Filter context applies on top of other contexts, such as row context or query context. So filter context is going to apply on top of the other contexts, such as row context and query context, that we have to remember. In a tabular model, there are many ways to create the filter context within the context of the client that can consume the model, such as Power BI reports. Users can create filters on the fly by adding slicers or report filters on the row or column headings. You can also specify filter expressions directly within the formula to specify related values to filter tables that are used as inputs or to dynamically get the context of the values that are used in the calculation. You can completely clear or selectively clear the filter of a particular column. This is very useful while creating the formulas that calculate grand totals. So what would happen now? There is a filter context which is applying, and because the visual is getting executed, the visual rows is actually having a particular value getting filtered. Now you don't want that kind of filter happening because of the visual row. So there are functions like ALL, ALLSELECTED, using which you can, you know, go beyond your context. You can completely clear or selectively clear those particular columns' filter context and get a formula which will help you to get grand totals.
So this is what we understood about different contexts. Now what you're going to do is you're going to explicitly look at this row context and filter context, and when we go to the visualization, quite a few times we are only going to talk about filter context, but by the definition you might see that it is applicable on a larger context or some other context, but we'll try to limit ourselves to use few terms, and I'm going to explain you what are the terms which we are going to use when we are going to look at these contexts in the visuals.
Let's understand the difference between the row context and the filter context and also look at the Power BI file to understand the different kind of context we have understood a few minutes back. So let me take you through the next slide. Let's have a look at the differences. So basically, the row context, as we have understood already, is a physical row of the table. So basically, when you're doing a calculated column, then what essentially you're doing is every row by row that calculation is happening, or basically row filtering is applying on every row. So you are only limited by the data of that particular row; that is where we say row context is applied. Now, similarly, when you use iterator functions like FILTER, SUMX, AVERAGEX, ADDCOLUMNS, you can also access the row context. So like say if you use in the SUMX, you use the sales table, then you're also creating a row context because at that time you are at the row of the table, and you can do that while creating a measure also. Now row context applies to one row at a time, not more than one row. Because we have multi-row context, if you remember, for that, a filter context, if you apply, how can it come? It can come because of the slicers or the filters which are available on the page. It may come because of the visual. So the visual has every row, and it row has a column or row because of which the values are coming, and they are coming as a filter context. DAX calculations, like when we use CALCULATE function, we are giving filter expressions, and those are also acting as a filter context. And filter context usually applies to a set of rows.
Now let's jump out to the Power BI file and try to understand the row context. First of all, if I go to my sales table in the table view, if you remember, we have done certain calculations, and one of the calculations which we have done here is the Gross Amount. When you look at the Gross Amount, what is this calculation? Sales quantity multiplied by price. Now this is a calculated column; there is no aggregation here, and this calculation is going to be done row by row. So here row context is applying, and you're only getting data of a row; you're not getting beyond that. Same way, we have COGS calculation, which is again the row by row calculation. Discount amount is again row by row calculation. But if I come to Sum of Gross Sales, if you remember, we discussed in the query context. Now here what is happening? The entire table is available when we are doing this kind of operation, and what are the other contexts applying? Now when we are on a visual, the other contexts may come because of a table visual or the bar visual or because of the grouping they are providing in the visual. Now here there is nothing which is coming in for that, and that is why you are getting the full total, and that, that is why you will find that I am keeping on mentioning this: whenever you are using an aggregate function in a column, it gives you the full table. So you have access to the full table, and to reduce that, you have to use some kind of a filter function or something like we have seen the example of EARLIER in multi-row context. So the same example we have here, the First Change Date, where we are using this filter function and EARLIER, a multi-row context. So here we are having this multi-row.
Context: basically, what is happening? Your customer ID equals to customer ID in the full sales table. We're finding out the subset of the rows which are satisfying these conditions in the sales table where current rules customer ID is equals to the customer ID of the sales table, and that subset of rows you're using to find out the minimum sales date, which is becoming your first sales date. Same way, we have also calculated the last sales date. So these are, you know, the calculations which are coming from multirow context.
Now let's go back to the visualization. In the visualization, if you look at this visual, this visual is having rows. If you look at this row, it is filtering the data for that row for category one. But also, if you look at the gross column, this particular row, it is not giving this total like what we are getting in the column because here the categories filter context is applying on this visual row and restricting the data to category one. So basically, what you call the data is getting grouped; so data is getting filtered for category one for this particular visual row. So here we can say that, you know, each row is getting a filter context of category. So when there is a category or there's a brand, each row will get the filter context of those unsummarized columns or group by columns, and because of that you are getting that particular value for each row. So filter context is passing. Now, additional filter context can be added from filters from slicers, and then that will further reduce your data for a row. So different kinds of filter contexts are getting applied on this one.
So now what could happen? You could go ahead and add a filter or a slicer and apply it to this particular visual, and that will also give you the context. So what happens? Let's say I can go here and put a brand; let's say I simply put a filter as a page, and I can select brand one. Now what you are seeing is this filter is also getting passed to this visual, and your result or your query context has changed to get the results. So now we are getting data of brand one for this visual, and inside this visual, every row like category one is getting data for category one; category four is getting data for category four. So the context is getting applied to each and every row. So now you might have got a little bit of an idea of different kinds of context and what would happen that, you know, when we are going to go ahead and look at various calculations, we will talk about that context. And sometimes we might simply use the generic term context, but looking at whether we are talking at the visual level or whether we are talking in a calculation—the calculation could be in the measure formula—you will be able to identify that which context we are talking about here; which context is going to apply when we use that particular kind of calculation, or when we are talking about a visual, which context we are talking about.
Let's understand how we are going to use various terms. So whenever there is a slicer or filter which is passing the filter context, we may simply use the term, okay, the it is getting filtered or it is getting filter context. Similarly, the visual may also pass the filter context, so we can say use the term context, filter context, visual row filter context, or row filter context. Means when the visual has, let's say, category or brand and it is filtering the data for that, also there is a filter context which is passing, but we will, okay, may use to explain you better, like, okay, this is visual rows filter context is passing. Now, when we use DAX formula and we have the filter because of that, we may say it is formula filter context or simply the context. This is how we are going to use the terms in the upcoming videos. Based on that, it will be helpful for you to identify which context we are talking about.
So now we will understand DAX query view. First of all, what we are going to do is we are going to go and look at the release notes of DAX query view to understand it a little bit in detail. And we are just starting with the DAX journey; I might not be able to give you a complete overview of what all DAX query view can do. So what we will do is first let's understand the basics of what DAX query view can do, and later on we will come back and explore DAX query view in a little bit more detail. So let's start the journey with the blog in November 2023. The feature of DAX query view has been released; an additional tab on the left-hand pane has been added for DAX query view. And this feature will allow you to run DAX queries directly from Power BI Desktop; you don't need external studios for that. Release notes of November 2023 talks about this feature, but very recently a detailed article has been given on blog.powerbi.com or powerbi.microsoft.com/slus blog. We are going to look into the article as well as we are going to play around with the DAX query view in Power BI Desktops.
Let's quickly have a look at the blog. As you can see, as a first thing, the various components have been explained. So we have the data pane here; we have the quick measures option; we have the command bar here, ribbon; DAX query view access via the fourth view option—the fourth view option which we are going to check out in some time; DAX query editor, which is this portion; and the result grid, which is this particular section. And then we can have query tabs; we can have multiple queries. How DAX query view is going to help us out has been described in this blog: quick queries from the data pane to make it easy to create DAX queries; direct model author can use DAX query view; new measure authoring workflow—we will see how can we create new measures directly from here; DAX query of the visuals; create your own DAX query. Now, those of you who are from the Power BI world and never used DAX Studio, uh, you might not have seen the use of EVALUATE. Now what happens when you want to evaluate a query in the DAX view or in the DAX Studio? You require EVALUATE, and then you write down EVALUATE and a query—a DAX query typically should return a table—so all every time we're trying to bring in a DAX query, we try to return a table, and then you say EVALUATE and the expression which returns as a table, and that's how you get it. Now, if you want to create something new or you want to define measures, then you use the DEFINE keyword, where you can define the measures. Now these measures are defined in the context of that particular query.
Let's read out the definition from here: EVALUATE, EVALUATE which is required, that specifies what data you want to see; DEFINE, which is optional, that can specify a measure or named DAX formula to use in the DAX query. This measure can already be in the model or not. If already exists, you can make changes that only apply to the DAX query to try them out. You can also have the option to update the model with these measures, which we will get into more detail later in this blog. So in this blog, they have shown you how can you save the changes in the measure, and we are going to experiment with that also when we are going to take the practical examples. Now, one example has been given for a DAX query; summarized column is one thing which returns a table, and that is how we can use it. If you go down, more examples have been given; also equivalent SQLs have been provided in this blog so that you can understand what's happening out here. As you can see, the queries are run using EVALUATE expression; SELECTCOLUMNS is another function which can return a table with the selection of columns what you want; and we have ORDER BY something which we don't frequently use in Power BI because we use the visual sorting, and visual sorting internally applies that ORDER BY, but here you can explicitly call ORDER BY function; then show data preview in the quick measure, then it will generate a query for you, DAX query, and you can run that. Few more examples, then you have DEFINE with the references. If you have a measure and you want to define its references, then you have an option. When you are running the query, you can see the DEF references has been defined; you can change the definition a little bit while doing the evaluation of that particular measure in the DAX view. So as you can see, some of the measures have been changed, and it is asking, do you want to update or override those measures? I may or may not want that; I'm just experimenting it here by changing it; what would happen? So you have a place where you can experiment how your different measures or different combinations of the definition is going to result in the data. And then few more things have been explained here. We have learned now quite a few visuals, and there are still few visuals which are left out, and we will take up those visuals once we are able to learn DAX and able to create more complex DAX. Once we are done with that, we will come back and we will learn how to use conditional formatting and how can we create some other visuals, and in those visuals we need few calculations which are dependent on some DAX. This time when we are going to learn creation of new measures, just like we created the measures initially, uh, we can take help of a new measure which is available on the top under the measure tool or table tool or Home tab, but we are also going to take help of this new feature which came in 2023, which is DAX query view. In the DAX query view, we will be able to put the definition of an existing measure, modify it, and get a new measure, or we simply define a new measure, and we will be able to use it. DAX query view is something very similar to those who have learned SQL; it's like in a SQL editor or SQL Developer where you write down the SQL statement and execute them to get the query result. So these are the DAX queries which we are going to write down here, and you will get the results.
So before we deep dive into the measures, we're going to learn a little bit about this DAX query view, and as I already opened it, you can see that there is already a statement: TOPN and 100 customers. We do have a table with that name. I'll explain you what this—so whenever we are going to do anything in a visualization, we are not going to use this EVALUATE function at the max. I will do this TOPN and 100. Now TOPN is a function which can give top values; 100 is the number of values; and customer is the expression or the table which I've given. So it's giving me top 100 customers. Important thing which we have to remember when we are in the DAX query view is that whatever we are writing down here, when we are to evaluate it, should give us a table, and there are many ways we can get a table; we will learn them as we go move forward. Now if we look at what all options we have on the top of the DAX query view, we have something known as format query. So if you write down a complex query and if you want to format it, let's say, can we format it further? Yes, this is how it will get formatted. You want to comment; you want to write down something; let's say we have written, "I will learn DAX," you can go and comment it here. You want to uncomment; you can uncomment, or these three lines are—I want to uncomment; I can go ahead and uncomment in one go. Comment; then we want to find something; we can use find and find it here inside this one; you want to replace something; and then you have a command palette where, you know, above the cursor, below the cursor, you want to search something that can help you. I want to execute a measure; how do I execute a measure or get its value in the DAX? Can remove this, and you can have multiple queries; you have tabs below to run the multiple queries. So what I can do here is I can go to one of the existing measures and I can right-click and say quick queries. I have EVALUATE, DEFINE and EVALUATE, DEFINE with reference, and EVALUATE; DEFINE all measures in this model. Now EVALUATE means simply it will give me evaluate expression; DEFINE and EVALUATE will give me definition how it's defined. Now, so let me add the DEFINE and EVALUATE. So it's giving me a function, SUMMARIZECOLUMNS. I'll explain you what this SUMMARIZECOLUMNS means. So let me evaluate this; first of all, I can also evaluate this without—so basically what happens in DAX query view that we need to EVALUATE and then we need a table expression. This is how it works. SUMMARIZECOLUMNS is also going to give us a table expression. What it does is you can have the name and then you can have expression, name expression, name expression; you can also add filters. This is how SUMMARIZECOLUMNS works. Now if the measure is in the schema or the model, you can use it, but let's say I want to change this definition of the measure; how does—we define a measure? First of all, let's understand now this one. So we first we say DEFINE measure, the table, and the measure name, the new measure name or the measure name which you want, and the definition, the expression basically. So this is our expression part; this is the left-hand side measure name part. This is how you define it. Now can I have the two definitions here? Yes, I—what I can do is I can say multiply by two, and I can keep a bracket to give the preference; multiplication anyway is going to take a preference. I can run this. Now you can see that it takes the new definition; the local definition would be given priority. You can simply say EVALUATE, then you see the old definition. Now let us say I want to define my own new measure. So what I can do is I can copy, and I'll say gross one. What is my gross one? What was my gross actually? My gross was SUM of sales gross amount; this was my gross. So what I need to do is now I need to add this measure, and before I tell you, I'll even tell you one single function which is ROW. What ROW function can do is ROW function can actually take a name expression, name expression, name expression, and it only gives me one row. SUMMARIZECOLUMNS is even more powerful; it can have a GROUP BY also; we have not added the GROUP BY there. So so let me execute it first of all. EVALUATE for the first time evaluated with net original definition of net because we have not used DEFINE. What I can do here is basically I can add a column name; a static column, and I'll call this as grand total, because ROW is giving me only one row; it's typically used also to create one row of data; ROW again, but it gives me a table name. So expression, name expression, name expression. This is what the syntax is: name expression, name expression; keep on going like this. Now the third one is gross; we created here; I'm not calling it gross one; I'm simply using gross, and then I'll use my gross one, and gross one is only local; it's not being created till now. So I got it, but what do you observe here other than, you know, it's giving me the data? Is update the model, override the measure, update the model, add new measure. These are the two new options which are coming in; it means if I want, I can add this measure, but right now what I'm doing, I'm testing it, so no need to do. Now we have learned about this thing; something known as SUM; you already know this. Same way as SUM, we have MIN, MAX, COUNT, COUNTROWS; measures are there. Now let's go ahead and do this. Now I'm going to create it, and then we are going to use it there also. So let me say what is MAX here, and let me call it as gross two, then gross three; this is MIN, MIN of gross amount; then we can have one more which is COUNT. Now I don't want to count the see gross amount; I want to count, let's say, order number, and remember my order numbers are unique. So when I go to new function which is DISTINCTCOUNT, which is going to count the distinct values; I'm not going to use order number; I'm going to use sales city ID. So what is my SUM of gross amount? What is my MAX of gross amount? MIN of gross amount? COUNT of order numbers? And what are the distinct number of cities in this? And I need to add all of them into my ROW also; it cannot happen that I—I just get it, and here I can use this formatting. Now let's do this formatting; every row we get this, and now you can—I can do that copy-paste; let me put a comma also here, and then start doing the copy-paste. We need gross; I'm—I'm giving a different name here; okay, GR; MIN is two; gross three is a MAX also, not following the order; and if you remember, I am not given name here; this is gross four. So let's call now gross four was there. So we will say count orders, and this way will say distinct cities; distinct cities; distinct cities; so correctly the name. Now let's run it. Now you're getting this. Now some of those we can create as a measure. So let's say I want this update as a new measure, and it is asking this change cannot be undone; means once I create, I can't undo; means I have to manually go and delete it; you can't use control Z; means it's going to update the model; we are fine with that, isn't it? Okay, fine; again I say update. So I used update again. Let me create MIN of gross also and MAX up and SUM we already have, so we don't need it actually. We will learn the SUMX function now in some time; then we will try to create it from here; we know an easier way here; copy-paste; copy-paste; and do it. I would like—now let's take an example of this visual here; data is grouped by category. So how can we get a similar kind of example in DAX query view? How can we get the grouped data? We will use SUMMARIZECOLUMNS or SUMMARIZE. Now these two functions have the ability to have group wise as well as aggregated columns together, and using that you can create a table which will give you aggregated columns as well as group by columns. So let's go ahead and try that out. So if you remember when we came initially here, we have been given a function which was SUMMARIZECOLUMNS. Now look at the definition of SUMMARIZECOLUMNS; what does it say? You can give GROUP BY; you can give filter; then name expression, name—we already using name expression, name expression. Why don't we go ahead and give a GROUP BY? How do we give a GROUP BY? We need item category; I given a GROUP BY; then I have name expression, name expression; and let's try out. Evaluate this. Now I can't evaluate it alone; I need to have the DEFINE also because there are few things which is not created as measure, and we are getting the similar kind of results here. We created additional measures; there is AVERAGE gross; if I want to add it, and without even defining, I can put a comma at the end and I can say average gross, comma, and if I use that, it starts suggesting me the measures; then I can use AVERAGE gross; it suggests me as soon as I type it. Let me run it. Oh my god! In this manner, this SUMMARIZECOLUMNS, everything which you want to use here should—finally the EVALUATE should return a table. Say what happens; I'm asking about return table; return table. What happens if I don't do that? Let's say I simply write down EVALUATE this AVERAGE gross. Now it is already available, isn't it? Let's select and execute it; it doesn't. So it needs a table; and start renaming it also. Let's say we call this table one; we call the first one is test; there's nothing there. What we're going to do is every time and again we're going to go here and create the measures by just copy-pasting, by doing a little bit faster stuff and understanding those things. So now we have understood DAX query views, and we also understood the basic functions available with us. What we are going to do here is basically—is there are too many visuals in this file, so at this stage we're going to remove all these pages.
I'll remove them one by one. And now we'll start learning Dex with almost an empty file. So what we have done is now we completely created the mt5 by deleting the page. We'll save this file, and we will also now do a save as. And in this save as, this time we are going to give it as a .n22 name also, but we are going to say this is the second file so that you can differentiate that's where we started learning the data analytics expression. And interchangeably, we might use Query view as well as the new major functionality here. Whenever we want to use that, we would like to learn about these conditional statement: if and switch. So while these can be used in column and measure, so initial example what we are going to take is here to learn these basics of these statement, we are going to use them in column, but they can be used in major. When we'll do conditional formatting, we will come across a situation where we would be needing the if or the switch state. So let me showcase you the syntax, and then we can apply it anywhere.
So I'm here on my table View, and inside the table view, the item table is already opened. I would like to showcase you that statement here: both the statements, so if a statement. And what I would like to do: a very simple thing. I have five categories. I want category one and two in group one, category three and four in group two, and the last category in group three. That's what I want. So let's start creating group using the if statement in a new column. So again, you clicked on a column, then you will have a column tool. If you clicked on the table, you will have table tool. In both, you have new column. Click on the new column. Let me start calling this column "new column is group one", and I'll start with if statement: if what is my condition? If category—because I'm creating a column, I can simply use the column name belongs to the table without using the table name, but ideal situation is use table name. Column—in why I'm using in because I have more than one value, or I can use R statement. In what and in we give here in the curly brace: "category 1", comma, double quotes "category 2" close. So what? What is the if statement logical test? What is the true value, and what is the false value? Now, because I have already created a True Value, I need to have another if in the false value. So I want to call this as group one, but for remaining values I don't have else. I again need a if. What if I need is I need to loop the if. So here what I'm going to do is: if category is three and four, then it is group two. So this is in the else of the first. Now what is the else of the second if I'm looping the if inside it? So the false state when it is false, what is that? Group three. I close this if is close, but right now let's focus only on this if. So we have a condition: when that is true, what is the outcome? When that is false, what is the outcome? This is one. Now look at the bigger if: this is the condition, when it is true, what is the outcome, and when it is false, what is the outcome? So true, false outcomes. I'm closing the first statement. I found there is some uh spelling mistake, so let me correct those. Now this is correct: Category 2 is in group one. Category 5 is in group three. Category 3 is in group two. Category 4 is in group two. Category 3 is in group two. Category 1 is in group one. Category 2 itself is in group one, and below that category 5 is in group three. Everything is correct.
Now we use this group. See this was only two if. What happens if you have so many multiple ifs? Then it will become a real big challenge, isn't it, to loop such things? So we need something known as case statement. We typically know, know in the SQL, very equivalent of that one, and we have something known as switch here. Switch, which is equivalent of case statement. Now switch can be used in two manners. So first we will learn switch where we can give a column and we can handle each and every value of that column. So the first we will learn the switch where we can give the switch statement with a column or with a major. Now here we have a column, so we going to give a column and handle each and every value, and then we will learn the another version which is switch true where we can give conditions like we have given in if. So let me start by creating another new column, and let me call that as group two. Now here what is going to happen is I'm will use switch. Now the switch I can have expression. Expression can be true, then I have value, result, value, result combination, but it can also be a column or a measure. So I'll use category as a column. Now when, because I used a column or I used a variable which is having value not true false, I need to now specify each and every value. So category one, what is the outcome of that? Group one. Now in this manner I have to now repeat this combination. So let me do one thing: let me move this comma from here to here, here, so that I can easily repeat it, and let me remove it from here. So now what I have to do is: category 1, group one. Category 2, what should be the? Category 3, category 4. Last one we can leave for else, which we can call as group three. Now here we need to change: category two is one. Category 3 is two, group two. Four is group two again. So this is switch statement with a column or a categorical value or something which is having a value not true and false. So we have one, three, same groups should exist. These values should match, there should not be any difference, and they are matching, you can see. So this is working. Now this means if I have thousands of value, I need to write it down thousands of rows. But what happens if I have a better matter to write it down? Can I use something which where I can give the conditions just like we have given in the case of if? Because think about numerical value where we have a range: greater than equal to Z and less than 5 or less than 1000. Will I write down 1, 2,000 values? No, I don't want to. I need something which gives me the that particular. So for that we have a switch true version. And to make it a little bit easier, I'm going to copy this statement. I'll click on any column and again create a new column. We paste this statement. I'll call this group three, and let me move it down. Comment it. Double slash is for comment. We'll use these things. So we start a new Switch. This switch is now this time with true. We call this as switch true. Now what happens when you use switch true? Your expression should return true and false, and then you have to use the value. So what is my first statement? My first statement is: category in category 1 and 2, then group one. I don't need to use if. I simply need to use one statement which gives me true and false. If it is true, this is going to be my result. So this statement should return true, and when this return returns true, it's going to give me this result. If it returns false, it goes to the next level. So here I don't need another if looping. Simply I give the next statement, and if this is true, this is going to take the next result. Now after I give all these condition, finally I can give one else, and then I can close the switch statement. So how switch true works: you give a statement, if it is true, what is my value? Another statement, if it is true, what is my value? And finally you given else values. True Values. True Values. Finally else values. So if there are if if if if, okay, please remember in such situation the order is also really important. Now what happens sometime when you deal with numbers, you have a choice of writing down between numbers, or sometime you can simply say. So let's say I say: if it is greater than 80, I can give the next condition as greater than 60, because greater than 80 is already covered in the first code, and then I can give greater than 60 in that order. So first is greater than 80, then 60. But if I put first greater than 60, it covers 80, so it cannot, you cannot have greater 80 after that. So the order of these conditions is also really important in some cases. So you to take care how which order you are going to give it. If I would have handled a multiple condition, and there is some kind of um priority I need to give. Whenever there is a priority which we need to give in switch statements, it always need to come before. Remember that, and based on that you will be successfully able to create switch statements.
Another column created, and we got the values here same as what we have got in the rest tool. Now let's create, start creating some expression function, and what I'm going to do, I'm going to go to the major Table, and there I'll create one of them, and then we will learn more and more details on the expression function as we go move forward. We will try with some basic expression functions first, and then we will go little bit detail into this one. But as we progress further into the deck, create more formulas, you will learn that we can do more powerful things. So let me create a table visual on a new page. I'll start with something which we discussed initially, but we have not done. If, if you remember, we have this column. If you remember, we had this column: gross amount is nothing but quantity multiplied by sales price. We also created a major on that, and why this is able to give a result? Got as usual, we are using sum of gross amount. So result inan, and this is creating an implicit measure. Gross is an explicit, some of gross implicit, and we when we will learn the calculation groups later, it will not allow implicit measure. So we'll only need to use explicit measure, and that's why I'm creating explicit measure. So at some stage you need to use calculation group, you always have the measures which are explicitly, so it measure and explicit me. Do I need to create a column first and then need to do so? This is is not needed. That is where the expression fun and expression function can be used both for column and measure. We learn how to use that in a column also. So first of all, I'm going to create a new major, and in this major I'll call it as Pro level th X. Now when I put this any expression function: sum X, main X, max X, count X, there is nothing for distinct count as of now. There's no expression function for that. For these is this is a table expression. Now this table can be as simple as table name. It could be a filter with Filter expression is going to give table, then there could be complex table Expressions which will include functions like summarize, all, all selected, all these kind of stuff would be there, and then we have an expression, the calculation or a major, already existing Majors could be there, or we can define here. Now when you use Simple table, it's fine, you can use set of column and calculation inside that, but when you we are going to do the complex measures, when we have the table expression itself is in complex, then we might have to use calculate few places inside the sumx itself in the expression portion. That we will learn little bit later. So let's start with very simple expression function here: sales, and we are going to use sales in the table part of the expression, and in the expression we will say: sales price multiplied by sales quantity. It means I'm trying to create a row level calculation. So what's happening here? This is my level, and as I've given the complete table, the table's row level is my row level. So this expression has to execute at the each row level, and and that's going to be little bit costlier calculation that compared to the simple gross which was simply a sum, and that is where we might have to take a call: should I create a calculated column and then major, or I simply create a major? It's a really small data, so it doesn't matter much here. In this case, it's going to give you same kind of performance. On a larger data, you might have to take that call. And if you look at the numbers, all these three numbers are same. The than the formatting we have done formatting on the gross, we can do on the gross row also. The results are same. The grand total is also same. Grand total is also same. Now we have used sumx. Same way, let's, if you remember, we done Min of gross and Max of gross. We not don't want to take everything. So this was gross two was Max. If I want to achieve the same Max using this one, can I achieve? So I copy gross row Max, and I can use max X here instead of, and Max X also having the similar syntax, and then we have a variant thir argument. Returns the largest numeric value or largest string result from evaluating expression from each row of the table. So you have this values which right now I don't want to use. Simply use this, and let me add it to visualization. It's giving the same result. Same way M. So this is the simplest way to start with the expression fun. Expression function can be used as the col column level also, but we will that little later. So now let's create little bit different version of expression function. So what I'm going to do here is now I'll create a new major, and in this new major I will use a filter. I'll say brand one Ross, and we keep on coming back to this. Then I can use filter here. Filter function. I'm using filter now. The let me try to use item here. I use item. I say: item brand equals to Brand one, question close. Can I use sales here? I'm not able to use sales. The moment I use a different table other than my table which is item, I can take anything from item here. I can I can count the item. I can count the brand. I'm not able to get that. So what I can use here is I can use the gross here. Major. I can use a measure here. This portion I use a filter which does not belongs to the table on which I'm using the filter in the table region. If I in the expression if I use a filter which is on a table on which final my column is not there, I want to do the calculation, then what I have to do here is the major expression can be a major. Al, and as you can see this is giving the correct value, but there's one more way. Now not for the brand one, let's say I want to filter something as quantity or something on the sales table itself. If I want to filter something on sales table, let's say gross sales one THX filter, I can use sales item sales sales Item ID equals to one, close the filter, and then I can use sales quantity. I can sum the sales quantity, or maybe because we are using gross, so we for us to know price. I got brand the item one is falling in this category, so I'm getting this. Now not only filter I can give this single value, I can also make do a little bit more complex stuff. So the filter expression could be really complex. I can have multiple conditions. I can use in or all those stuff I can do. We that we'll learn when we are doing calculate, but one thing I would like to tell you before we move ahead with the more complex functions is that I can here I can say: let's say sales qy quantity sales quantity greater than let me call it as gross sales. So now it's going to sum everything which is greater than two. You remember we have done some kind of visual level filter for that. Now there's no need of visual filter. I have actually made it part of the EXP function. So this is very basic start of the expression function do, and as we progress further we will learn more complex which we can do. So let's Now understand the difference between filtering a data in calculate with and without filter function. So let's say we want to give a filter expression in the calculate without using a filter function. How would we give? Let's say: calculate net item brand equal to Brand one. We want to use filter function. How would we give? We'll give: calculate net filter item item brand equal to Brand one. Now when the visual will contain brand into the visualization, you will see a difference. You might not see difference when when item brand is not in the visual context. So you may not be able to see that difference if we are having the visual on category, because at that time the visual filter context is not filtering brand, it is filtering category. So you might not see the difference. So what's the basic difference when we do this? So the calculate function without a filter function, you directly apply the filter to specific column with the calculation. This modifies the filter context and effect how the expression is evaluated. The calculate without a filter expression applies filter directly to the column, altering the filter context and impacting the calculation. So it's alter the filter context, and later on you will understand that it is basically what it is doing. It it is removing the item Brands filter context in the visual. So is basically it is saying like all item brand and then brand equal to Brand one. So your row of the visual which is actually showing you brand 1 2 3 4, that filter context of visual is not getting honored, and you are still getting the data of brand one, but it is going to display played against all the brands. This is what is happening. So I'll explain you when we go to the power BI that in such scenarios what this first statement is equivalent of. Now using filter function with calculators allows you to create a filtered table based on specific condition. So basically the data is getting filtered. This offers a more flexible approach of defining the filter context and customizing the calculation in interacts with the data. Calculate with a filter expression construct a custom filter context by creating a filter table based on specific criteria and Returns value based on that. So basically your data itself is getting reduced. So basically what happens when you use this filter function and let say you use with the brand, because the data is already getting filtered, you only have the brands one data, you're going to see only brand once row. So these are the main differences, and we have to understand that with the example. Now we will understand this calculate functions little bit more in detail then we don't use filter and simply try to filter the data. What happens then? So we will bring in our calculate page from here, and in this one had major bring this visual copy paste. Now in this one I'm I only right now bothered about how do we calculated this brand one net. That's understand brand one net was so brand one net was calculate net. We use a filter. So when we are simply using the filter function, it is filtering the brand one's data, and that is what you are able to see here that you're only seeing the row which contains the brand word data. So the data has been filtered to give us only data for brand one in this case. Let's try a different way. Actually we can also do, we don't need a filter without using the filter fun item brand one. It's call it BR. In the first case what was happening when you use the filter, the data was like second case. And if I would have removed this one and this one, it's actually only going to give me brand one. In this case if I bring in, it's first is going to bring all the brand. So here brand columns is filtering brand one, which means the filter is applied to all the rows, and there is no filter to the table. Filter retains and interacts with the initial filter context while filter expression directly in calculate ignores it. It means that filter contexts on the brand one overrides the other filters which are inside the visual specific especially visual rle as well as outside the visual. Let me do one more variation of this. I go and put here category instead of brand, then there's no difference. Only when I view it by
Brand: When it is brand, uses a filter without filter function, it's giving me the brand one value everywhere. This is something really useful when you want to use only brand one's value, or whatever you filter that value you want to use across the values. Understand this thing: the filter of brand one has been applied on the row; every row is only giving you brand one. So what's happening in this case is basically the brand one is getting filtered, and that particular value is available now for all the rows of the brands. So whether it is brand 2, brand three, Brand 4, all the brands are going to show you only brand one's value. So we have the brand one value displayed against all the brands because the column has been filtered for the brand one.
Now, how can we achieve this otherwise? What is the equivalent of this? Can we understand it better? To understand it better, let me tell you the equivalent of which will help you to understand. Let's go back to this one, calculate again what it is equivalent. Now we already understood, all you understand, if I use all item brand here, what would happen? It would remove the context. So when we are using this all item brand, what it is going to do? It's going to remove the filter context of item brand. Means if you filter the data for brand, it will not apply, neither it will apply the Brand's context in the visual. So in the visual row, if you have a brand three, brand four, brand five, that is not going to be applied. So this has been entirely removed.
So what should I have given? If I simply say all item brand grand total, but now what I'm saying after that is, now let's put the filter of item brand equal to Brand one. What is happening now? You have all the item Brands, out of which you are only bringing in brand one. Now what we're going to do here is we'll bring this in. Let's bring it inside the visual; it's the same as this one. So what's happening now is that in the visualization, when you're going to see the each row which is talking about a brand, it is not filtering the brand because of all item brand, but it is getting the value of brand one because what we have said: all item brand, then filter the item brand equal to Brand one. So it is only getting the value of brand one for each row. So the filter context has been removed, and especially when it is displayed in the visual. So especially when the brand itself is appearing in the visual, the visual's filter context of the row is also getting removed, and based on the value which we have filtered here in our measure, based on that only we are getting the value displayed.
Sometimes what would happen if you think that I'll just simply say item brand equal to Brand one, or item brand equal to brand one, brand two, brand three, or I use the or statement? It's going to be same as what I use in filter. That's not it; it's not same. Calculate with Filter function and without filter function are not same; remember this when you are doing your calculation.
Now we would discuss the differences between all and all selected. Let's look at the very simple syntax of all and all selected. So now this is net all, means net calculate net and all, and in all I can specify a column here and table here. This is without specifying anything. Similarly, net all using calculate net all selected. Now what is the difference in between these two? So basically what happens, as we have learned in the past, we have something known as filter context. Now filter context may come because of slicers, filters, or maybe because of the visual. Visual row is also going to put a filter context on the data. Now all is going to remove everything. We'll learn this with an example. All disregards the filter on a specific column or a table to retrieve unfiltered data for the calculation. For the every value, it's going to do that on particular column or a table, whatever we have used there. Now all selected preserves the user selection of filter. So user selection of filter that you have done, that filter context would be preserved in the specified column while removing the filter from the other column, allowing the selective adjustment. So this is going to happen in the all selected.
So what is in short we can say that all ignores the filter context, including the filter and the visual filter row context. Means the visual row which is going to put a filter context, that is also going to be removed. But on the other hand, all selected is only going to ignore the visual's filter context, which is basically because of the row of the visual.
Let's understand with an example. Let me come up with brand net visual, make it as a table visual. Duplicate this, create a little smaller visual with category. I'm adjusting the sizes. In the second visual, I'm clicking on the brand arrow and then I'll make it cut. I need like slicers also, and I'm going to use a simple slicer here. I'll use brand slicer, copy paste. Let me change this with category slicer, copy paste, and state slicer. I added three slicers in this one. I'll use State. I have three slicers. Let me convert this one into drop down. Instead of net, I've taken margin here, so let me correct that clearly here: net. Net is the measure we are going to use predominantly in all of calculation, but let me sort it descending here.
Now what I want here is I want a grand total. We'll take help of calculator. Let's create a new measure for the grand total. Click, click on any of the major and get a Major Tool, and here we will go ahead and say total net brand. So we'll say calculate this. Calculate, we can use the expression also, but we'll start with net. Now there is function all which can help us. What does all can take? All can take, all can take table or a column name. What is there in this column is, let's, why don't we start with the column name that we use: item brand. I drag it here, and here you can see I'm seeing grand total. Let me put it to other visual. In other visual where there is a category, I am not seeing that grand total on each row. Why it is happening? Because here in the case of brand, I am saying all item brand, and it should remove the filter context of all item brand. So the filter context of item brand has been removed, and that is why each row of the brand is giving me the grand total, but we have not told that to remove the filter context of category, and that is why what you observe that the filter context of the category is not getting removed in the visual rows. Visual rows are still applying the filter context of categories, but the grand total is not getting that filter because in the grand total now again we are able to ignore the filter context. Now when I select brand 3, now what is happening here is you are only able to see brand 3's value. When you see brand 3's value, you will observe that in case of the brand visual we are able to see the grand total value. External filter or the filter which is coming is going to reduce the visual to only brand three, but the context of the filter has been removed from the visual row. The context of the visual and the context of the slicer filter has been removed, and we are getting grand total both in the row where I'm getting brand three as well as grand total. While in case of the category visual, we are getting two categories. Now we are getting two categories because of the brand 3 again, because brand 3 contains two categories, but for those categories the category filter is still applying. So because of that category filter, I'm getting the data for those rows based on the category, but the grand total again I'm able to ignore item brand; I'm getting the total one. Now if I add brand two and brand three, as you can see in the brand visual I am getting both the rows. I'm getting the grand total which is ignoring the visual as well as the slicer filter context, and as you can see in the category visual, as expected it is able to use the category filter context in the visual, but the grand total again it is ignoring all the filter contexts because in the grand total anyway category is not available, and I am able to get grand total.
So we got total net work. What happened? Need both case of category and item. Int category and item belongs to same table. Is it what I can do here is I can go ahead and create this measure again, and this time instead of item brand I simply use item. What happens? I'll call it total net item. I'll bring it into the first visual, I'll bring it second visual. Now in this case what you are observing that both the visuals are showing the grand total, even the categories filter context and the brand filter context from the visual has been removed. The reason for that is basically, basically that we are using the item table. So any which we are using from the item table in the visual will not be able to force a context. Similarly, the slicers will not be able to force a context, and the visuals will not be able to force the context. Even if I remove those brand two and brand three, now you will see all the values, and in case of all the values again we are going to get the total for all the rows because the filter context of all the brand and category has been removed from each row, and we are getting grand total in the each of the visual. But what happens when I put the state filter? Let's say I put the state filter on Alaska. Now you are seeing that the filter context is applied, but the visual rows filter is not getting applied. We are getting the Alaska gr. Why it is? Because again the filter was on item, for the specifically for the second column, so it is ignoring the items filter context, but it can't ignore the states filter context because we have not talked about the state into our formula. So because we have not talked about the State into our formula, it cannot ignore the filter context or the filter of State in the visualization. So visualization will get filtered for the state, but it will remove the context of brand and category because we have said all item.
What can I do here? Here comes my third all formula, and the third all formula is when where we're going to remove everything. Now all can have multiple columns. If you want, I can say sales, or I don't say anything, one of the two things I can do. I'll have this two formulas in one go. So I'll say total net Els one major. I can have one more version of this one without this one now, because all the dimensions are getting applied at the S. So most of the time these may end up giving us the same result. I'll bring in net, and let's not add it to the second one; there's no need of that. Now as you can see when we have bought this total net and total net sales where we have used the sales table, it is also start ignoring the states context. Why it has been started ignoring the states filter context? Because the all has been applied on the sales table. So anything passing to the sales table is getting ignored. If you apply the filters now, if you apply let's say brand filter, your values will reduce because this is going to reduce the values in the filter, but the rows which are still remaining for that, the filter context the way all is removing will still apply same way. If you filter category again, you will get the data of brand and category based on your filter only that much categories or that much brand, but yes in the for the individual row of the visual the filter context would be removed. Complete filter context would be removed, but what does it give us? It gives us the gr. This is all for us. Let's learn about all select. For that what I'm going to do is I'm going to duplicate it. Want to keep everything as is, removing the filter, and let me do one thing. I'll keep only this one because rest of the behavior in case of all selected is going to be same. What's the major difference between all and all? Let's start now. Let me create this measure with the all selected. So what's the difference between this all and all selected? So in case of all selected what would happen here is basically all selected is going to honor the filters which we apply, but it is not going to honor the visual rows which are putting the visual filter. The visual rows filter contexts would be ignored, but the filters filter cannot be ignored. So let's say if I put filter on brand 12, you can see that the all selected is showing me only the brand 12's value. It is not showing me overall value, why? Because it is going to honor the external filters or the slicer which has been applied. Within that boundary it will show me the total. So if I select let's say brand 12, 13 and 2, now it is showing me total of these three for all selected one. So it is ignoring the visual row filter context. Now let me modify the other visual, the same job. What I'm going to do is I'm to change this, instead of category I'll bring in state here from the geography Dimension. Let me go ahead and remove these two and bring in total a little bit more WID for this. What do you see? So what you are doing here is you are saying the ignore the filter context of item, not of state, and because you are not ignoring the filter context of State, the state values are still filtering your visual rows and you are getting the state level data. I do this, we go and ignore the context of Sals table itself, Sal item n it's all selected. I'm saying ignore all the context which is coming to this. This I'll add this the first table. I'll add this table, and we require a lot of overlap. Now when I use the sales, now what happened? The all selected applies on these sales. All selected now is going to ignore anything which is coming to the sales table, and because of that now you are going to get the total which is of my selected values, and it will be displayed for each row. Now in case you apply a state filter, it will honor that also now. So whatever filters you apply that will be honored irrespective of what dimension they are coming. So your grand total will depend on the filter selection in case of all selected, and based on that particular set of filters it is going to give you the grand total. You can have an all selected without the sales table. This case we to give almost similar kind of results because the sales table is the base table where we applied or the base back table where we applied. So now you have understood the difference between all and all selected. So there would be times when we are going to use these, especially in time intelligence. Let's say I want to create a previous period. You might not select a previous period because previous period might not be in my filter criteria. So let's say I selected current one. Now when I selected current month, I need previous month. I need to ignore date tables filter context completely and then bring in the previous month's value. So in that case I'm going to use all, but if the values are available within my filter context and I want to play around, then in that case what I can use, I can use all selected. So let's say I want percentage of total irrespective of my selection, then I'll use all. Or I need percentage of total based on my selection, I'll use all selected. I use, I want my rank rank based on the original values without considering any filter, I'll use all. I want rank based on my selection, I'll use all selected. So these are the some places where you will use all or all selected depending on what exactly you wanted to.
Let's learn about remove filters. Let me bring in state and city here. Create it as a table visual and add a net also. Let's have a filter MD space. Click on filter, we'll get it here. Control C, control V, second dimension, take one from geography Dimension that is State, take one from item Dimension that is brand. We got our visual. We have certain values and let's make it as a matrix. In the Matrix visual, build visual, we have the to. Now create a measure net all. What would happen? Calculate net all geography City. It we bring it here, what we're seeing that, look at this, the state filter is not getting ignored, only the city filter is getting. If you apply some filter that filter is obeyed, and if you're applying some filter which is on state that is getting obeyed because we said all of City, not of state or not of geography. Take this and now we use remove fi. This is something which we are also trying, which is also known as exclude exclude level of details. So we are trying here is excluding the level of details. So the city is present, but we are trying to ignore that, but we got the remove filters. Now what is the syntax of remove filters? Remove filters table or column name. So in this case we want to use column names. You can have more than one column names. We can have geography City here to ignore this one. Remove. Same results we are getting; it's almost same. I filter brand one, the results are same. The brand one is going to pass the remove cities here again. The state filter is going to pass to check the cities filter. What happens when we apply cities? It's almost behaving like your all filter, removing the contract. It's easy to remember that okay, I'm removing something. Now let's bring in city as a filter. Drag City here, create it as a slicer. As you can see this is net number is smaller and the all number and remove filter number is bigger. Basically the filter context of C, and we can have multiple columns as per requirement. So we can in the remove filters we can use multiple columns. If I want to add State here, I can add State. They are all from same table. This is what we call exclude level of detail which can be achieved using remove filters.
Let's learn about all except. All except is something like, you know, means ignore everything other than. All except. So I copied a visual from the other one, and let me remove few of things here. Let me bring in net. So let's say I want to remove all the filter other than it. Let's bring in the filters also. I name the pages. I want to create a measure which should ignore everything other than geography St. We create a measure net eight, let say calculate. Calculate can take various things. Now you might have learned till now all except. What does all except does? It takes a table and the column name, table and the set of column names. So table name could be the table for which you are going to give the column, and the beauty of this function is it can take a fact table and related Dimension. The one side tables can also be, but we will start with geography table is compulsory here, and then we'll see geography 8. What we are seeing, you only obey geography 8, no other filter. Now we bring in here, and as you can see that it ignored the city filter in the visualization. Okay, very good, it ignored the city filter, but what happens if I put a filter of brand? Filter of the brand coming from other dimension is not getting ignored. What happens if I selectricity here? This filter is applied, but the state is getting filtered because of this city. The Texas is the only data which I'm getting at the row level, and there it's ignoring the city filters, but overall it is Texas only, and we know anytime we apply a filter, but in the ground totally ignoring everything. So whenever we apply a filter, or what we can call external filter or slicer, it is going to reduce the value in the visualization. Means your categories, your cities, your city state category brand subcategory are going to reduce on based on what you have selected, but now within that selection further we can ignore the filters, even the filter which we have applied externally, its value can be ignored while showing the value. Like I will still be able to show grand total or a total of a state or a total of a city ignoring that filter, but I can't go beyond the set of values which is defined by my slicer or filter. You to remember that.
That's also fine. So what does it mean that the filter from the other dimension continues to pour in further? Let's duplicate this, and here in this visual, now me open the build. Instead of C, I want to bring in I category. I want, let's say, use category. What do we see here? There is no total, all except state. It is still considering the category; it's not removing that; it's not removing category. So it's not the state total. State total is only coming at the state level in this visual. But in this visual, if you would have the state total, it was coming in. Why is it so? Because what we have said here is that in the geography table, you only obey a filter. Now that's what it was doing. It worked for geography dimension, state, and city, but it is not working for the item dimensions category because our formula was only talking about geography dimension and geography dimension state. There was no mention of item category dimension, and and that is why when the major we have used there with the category is not able to ignore the category filter in our visual, ual and is still giving the category level data filtered based on the categories. Proc is not how do I do that, and that is something which is famously also known as fixed level of detail. I want to fix it; I only want that one. How do I achieve fixed level of detail in this major? Let's go ahead and try that out. Copy this and new major and can all accept give me me a fixed level of details. I use sales here, sales, and after that geography state, and that's what I told you also that all except function, you can give the central fact table, and then you can use one side of the table in the relationship. You'll call it all except net, all accept. Let me bring in this; no differences. But when when I put the brand filter, you notice one thing that my state totals are now ignoring the brand filter. Filters are no more considered. Look at this total; when I put the filter, the same. Let me go to the second page; let me put this here, net all Excel, and now you see that this portal is same and it ignored the category also. It is like fixed level of details. So level of detail has been fixed at the state level; it's giving me the state value, and definitely state is in the context. That's really important. So in this manner, all except can help us ignoring filter. Now now you can have multiple of them. Like in this case, if I simply would have wanted category and it, I could have done that because it uses a central table. It's not like all or all selected where you can't have from the related table. Here you can have item category and you can get the result same as this one. Why? Because it's going to obey the two filters; it's going to obey state and category. Now it's obing the two filters, state and category. This is going to remain same. Now let me filter the brand. Now when you look at here, this total is different from this one. This is 90; these all are 90. These are the my category 1 and category 4 total. So remember 24,000 and 16,000. Let me go back and remove the filter of brand one. You are having this is category 1 24,000, category 16,000. These values remain intact when I any filter. Now if I add one more child here, this visual, I'll go ahead and add let's say it and explore that the next level. What you will see here is look at this; this category a total is still intact because of all except category. State level is it at the state level? City is getting ignore. This is how you use all except.
So let's now understand the difference between filtering a data in calculate with and without filter function. Let's say we want to give a filter expression in the calculate without using a filter function. How would we give? Let's say calculate net item brand equal to Brand one. When we want to use filter function, how would we give? We give calculate net filter item item brand equal to Brand one. Now when the visual will contain brand into the visualization, you will see a difference. You might not see difference when when item brand is not in the visual context. So you may not be able to see that difference if we are having the visual on category because at that time the visual filter context is not filtering brand; it is filtering category. So you might not see the difference. So what is the basic difference when we do this? So the calculate function without a filter function, you directly apply the filter to specific column with the calculation. This this modifies the filter context and effect how the expression is evaluated. The calculate without a filter expression applies filter directly to the column, altering the filter context and impacting the calculation. So it's alter the filter context, and later on you will understand that it is basically what it is doing; it it is removing the item brand filter context in the visual. So basically it is saying like all item brand and then brand equal to brand. So your row of the visual which is actually showing you brand 1, 2, 3, 4, that filter context of visual is not getting honored, and you are still getting the data of brand one, but it is going displayed against all the brands. This is what is happening. So I'll explain you when we go to the power BI that in such scenarios what this first statement is equivalent of.
Now using filter function with calculators allows you to create a filtered table based on specific condition. So basically the data is getting filtered. This offers a more flexible approach of defining the filter context, and now we will understand this calculate functions little bit more in detail then we don't use filter and simply try to filter the data. What happens then? So we'll bring in our calculate page from here, and in this one add measure, bring this visual, copy paste. Now in this one I only right now bother about how do we calculated this one one net. Let's understood brand one net was brand one net was calculate n we use a filter. So when we are simply using the filter function, it is filtering the brand bu data, and that is what you are able to see here that you're only seeing the row which contains the brand word data. So the data has been filtered to give us only data for brand one in this case. Let's try a different way. Actually we can also do we don't need a filter without using the filter fun item brand one. Let's call it brand in the first case. What was happening when you use the filter, the data was second case, and if I would have removed this one and this one, actually only going to give me brand one. In this case if I bring in, it's first is going to bring all the brands. So here brand columns is filtering brand one, which means the filter is applied to all the rows, and there is no filter to the table. Filter retains and interacts with the initial filter context while filter expression directly in calculate ignores it. It means that filter context on the brand one overwrites the other filters which are inside the visual, specific especially visual rule as well as outside the visual. Let me do one more variation of this. I go and put here category instead of brand, then there's no difference. Only when I view it by brand, when it is brand uses the filter without filter function, it's giving me the brand one value everywhere. This is something really useful when you want to want to use only brand one's value, whatever you filtered that value you want to use across the values. Understand this thing: the filter of brand one has been applied on the row; every row is only giving you brand one. So what's happening in this case is basically the brand one is getting filtered, and that particular value is available now for all the rows of the brands, whether it is brand two, brand three, brand four; all the brands are going to show you only brand one's value. So we have the brand one value displayed against all the brands because the column has been filtered for the brand one. Now how can we achieve otherwise, and what it is equivalent of, and we understand it better to understand it better. Let me tell you equivalent of which which will help you to understand. Let's go back to this one, calculate again. What it is equivalent. Now we already understood the all you understand if I use all item brand here, what would happen? It will remove the context. So when we are using this all item brand, what it is going to do? It's going to remove the filter context of item brand. Means if you filter the data for a brand, it will not apply, neither it will apply the Brand's context in the visual. So in the visual row if you have a brand three, brand four, brand five, that is not going to be applied. So this has been entirely removed. So what should I have given? If I simply say all item brand grand total, but now what I'm seeing after that is now let's put the filter of item brand equal to Brand one. What is happening now? You have all the item Brands out of which you are only bringing in brand one. Now what you're going to do here is you'll bring this in. Let's bring it inside the VI; it's same as this one. So what's happening now that in the visualization when you going to see the each row which is talking about a brand, it is not filtering the brand because of all item brand, but it is getting the value of brand one because but said all item brand then filter the item brand equal to Brand one. So it is only getting the value of brand one for each row. So the filter context has been removed, and especially when it is displayed in the visual. So especially when the brand self is appearing in the visual, the visual filter context of the row is also getting removed, and based on the value which we have filtered here in our measure, based on that only we are getting the value displayed. So sometime what would happen if you think that I'll just simply say item brand equal to Brand one or item brand equal to Brand one, brand two, brand three, or I use the or statement, it's going to be same as what I use in filter. That's not it's not same. So calculate with Filter function and without filter function are not same. Remember this when you are the calculation.
Now let's learn earlier function. This function will allows us to get the current row value. So as you have learned when we create a calculated column and we do let's say sum of that column, it gives us the total of that column, but we always don't need it. So definitely we require filters. Now while doing that filter, we need the current row value. Let's say I want to get the customer first sales days or purchase date for the same customer. I wanted to find out in the entire table what is my first purchase dat. So there earlier can help us to check that out. What we I'm going to do is I'm going to go to table View, and inside table view I'll go to the sales table by clicking on that. Now I able to see my sales table. Now in the past I have shown you when I done sux sales gross amount, it has given me the total amount. What I would like to do is I would like to create a new column now which I can do by clicking on column tool because I already clicked on a column. So column tool is visible, and inside column tool I have a new column. Let me make F little bit larger, control and middle Mouse button scroll. Now the column which I want to create is the first sales date. Basically what does need? I have a sales date in this row, and I have a customer ID, but for that particular customer ID this might not be the first sales date. I want to find out what is my first sales date for that customer ID. There are couple of options I can use, but I would like to use Minx. I want to find out the minimum date filter. I want to filter the table. How do I want to filter this table? Sales table. I want to filter now. Complete sales table is available as you know the this is a column at the moment. I say sales table, complete sales table available. What I want is I I want to look say sales customer ID equals to what customer ID? So one way is I take the customer ID value in a variable. If I don't want to do that, then there I can use function earlier. If I use earlier, I can again give sales customer ID. This means current row customer ID. The customer see understand in the filter when I say sales table, the complete sales table is available. When I say sales table customer ID, complete tables customer ID is available. Now I'm saying current rows customer ID. So I got the current rows customer ID. Now the table only contains the current Rose customer ID, and from that I want the sales tables sales date, minimum sales date. So for this particular customer, the table is getting only that portion of the table which is equivalent of the current customer. You can see that particular partition of the table I'm getting now, and then I'll get my minimum sales date from that particular partition. So let's do one thing. Let's see is this date equal to the current date? Because if this date is equal, then this might be the first record we are in search where this is not equal. So this is not equal. So we can filter on this customer. So the customer ID 2954, we can filter on 2954, and there are so many records, and if I now go ahead and sort ascending, I've done a sort ascending here or this particular customer ID. Now let's look is this date available for all these? Yes, the 1119 date is available for all the rows. That's the first. Now with earlier you can have little more complex calculations also. It's not that you can have the simpler calculation like this. Let me clear out and take one more example. Let's say you want to find out what is my last sales date, you know for this customer, this is my first sales date, but I may like to know what is my last sales date, isn't it? What is my last sales date? Now the last sales date becomes a little bit more more tricky, and we need to add more conditions. How so? Let's add a new column and try to understand what is my last Sal date. Now look at this column first. So in this case what is happening when I'm comparing customer to customer and I'm taking minimum, then I'll get the first date. Next thing what I need to do, I also need to consider the sales date. I want to know that sales date which is before current row sales date, means sales date is strictly less than the earlier sales date, and then I need maximum out of it. So customer is equal to the customer, Sal state is less than the sales state in the current row, and whatever data you are getting from that data, get the max dat. So let's copy this formula. So we'll get last sales or last purchase, not the overall last, last is date, and here let's start writing down again. So explain you once more, Maxx. Remember this thumb rule when you go into the future, typically you will require the minimum. So somebody says what is my next sales date, the typical formula would have been Minx greater than this date. I need Max but less than current; in that case it would be I need the last date. The last date is less than the current row date, but it is Max out of all those. So filter sales sales customer ID equals to earlier customer ID, means current rows customer ID, and sales date is strictly less than earlier sales Sal date. Now I got a partition where all the dates are less than the current date for the same customer. Now let's get the max out out of those sales date. So now we got our formula for the current customer, the sales date which is less than the sales date at the max out of that. Enter, you can press enter or click click on this button, commit button, you will get this answer. For few of the rows you might not get it, but for few rows you'll get it. So let's filter 2954 once more, equals 2954. Now sort ascending on the date, already sort ascending. Now row was 19, so we are getting 19 here, and let me do one thing, we make it little bit smaller. So let me compare the dates now. Well, so 1912 to 17, 1912 to 17, Trail by one row. What we have done here basically we got the data which is trailed by one row here. This is basically previous date or the last. In this manner you can use earlier. Now there's one alternative which I should also tell you that in case sometime what would happen, I'll tell you when you want to use earlier function, you cannot use any calculation here like I want last month or something, we need a EO mon function, so on earlier function doesn't allow you to do that. In such scenario I'll give you the alternate of this one only by clicking on again new column. I'll tell you how can you achieve this, and in that case I'm going to create a variable. So variable uncore cust means customer equals to no need of earlier here, simply give customer ID, and then you can give underscore C, and remember that whenever I create a variable I used underscore so that I can differentiate. Then you give variable where where means what happens in a formula or in a measure when we use variable. So this is the syntax; let me explain you. So you used variable, then you use the variable name, and then you use the column. In case of column it should be column; in case of major it should be a major, or it can be a filter condition. We will learn when we do now. Second one is I want date, so simply I current rows date, and then I can use that as underscore sales say date. Now when when you use variable, you need to write down a return statement. So how my formula is the name equals to variable variable name and the variable formula written statement and the formula after the written statement. Again I don't need earlier here; I need underscore date. Dex is not case sensitive, so whatever you small or uppercase combination you can mix and match and do it, and let me press enter. Uh, we have the same name; we it will not let me rename this as a date one. Press enter or you can press the commit button. Now we got the same results that we had previously. There is no difference in this one. You can use function earlier. So you have learned how to achieve the same result with and without earlier. The advantage of these variables is that let's say I want to get the date in the last month, I could have used here F function EO month and got the last month end date, and I could have compared with that with the last month end date. That is little bit more flexibility I will get if I use variables. Depending on the need, you can use earlier or you can use variable.
So let's start learning the search function. So let me go to the table View, and inside the table view I'll open the geography table. So search function can be used both in a column or a major. So first we will take the example of a new column, and then I'll also tell you how can you use it in a major. So let me click on a column, and I'll get a column tool, and inside the column tool I can press new column, create a new column, and in this column I would like to search City. I can use function search SE. What what search function does for us? It takes a text, means the text which I want you to search within the text; it can be another text or it can be a column in which I want to search. Start position, if I don't want to start from the first position, I can give the from which position I want to start the search, and not found value. If I don't find a value, what should I return? So basically it's going to return return the index of the first letter. So let's say you search for new and it find new starting from fifth position, so it's going to return return five. So what if it doesn't find? You can return return a not found value. If you don't want to return let's say zero or something, you can return return blank, but prefer to return return a value. What I want to search? I
Want to search "new"? Now, search is not case-sensitive. And because search is not case-sensitive, what I can do is I can write down "new" as "NW" all caps. Then I can give a column name. I could have given a string where I wanted to search this, but here I'll give a column name. Start position: I want to start from the starting, so I can leave it empty. If it doesn't find it, I want to return zero. It means I'm going to return a position zero if it is not found, so that I can identify it is not found. But I can do here is I can go ahead and do sort descending. Here, sort descending means it will sort the column on higher Value First. There are only three values which contains "new", so these are the three values which contains "new", and they are coming on top now. So this is how you use basically the search function.
Now, what you have to do to use it in a measure? So simply what I can do is I can search this and I can use that as a result in my filter. So let me give you a quick example of a measure. I'll create a new page, and in this new page I'll bring in City, and I'll force this to become a table visual. So once you click on a visual and then you press another visual type, Power BI automatically changes it into that particular visual. Now I need a measure, so I need the count of the Cities which contain "new". This is my simple, very simple requirement: I need count of the Cities which contains "new". So, click on a new major available on the Home tab, and major name is "Count new cities" or "cities which contain new", but to just to keep the measor them little bit short, I'm doing this: calculate. So I'm saying I want to calculate count geography cities. I would like to count the geography City, filter the geography table, search what I want to search "new". I can give in any case because it is not case-sensitive in what column? Geography City column. And let me write down "geography City" because I have City in the customer table also, so just want to confirm I have used filter in the filter. I used geography is going to take geography City, but just for the clarity I'm putting it here. I don't want to give a start position, zero, and I can say greater than zero.
Now, there could be few versions. I'll tell you there's a function "count rows" also available with us, so you can do it like this. Or I'll tell you one more function which you can achieve it easily. Let me create a new major, and instead of all these I can use "found rows", and inside that I can give a filter condition, and I can create another measure. Let me rename it as one. Now you might be surprised why I'm getting only three rows. I'll tell you the reason also. What happens is any row which is getting filtered by the filter clause for which we are not getting a result, means the value for that is blank, and blank is not zero. Okay, for value for which is blank, it will not appear in the visual. Both the measures right now in the visual is only giving value for these three City. It is always the super set. Let's say if I put "net" now, and "net" has value for all the cities, so all the cities will appear, and we will get blank values for. So these are the quick example how can you use a search in a major or in a new column.
So let's now learn "find". We will go to the table View, and inside the table view in the geography table we will try to use it. We have already used search here, the search and the find have the same syntax. The difference is the find is case-sensitive, and also you cannot use Wild Card characters in The say search. You can use Wild Card characters, but in find you cannot use it. Again, find is case-sensitive. So let me copy this because I clicked on a column; I'll have the column tool available with me, and inside that I have new column which I'm going to click and paste this, and I'm going to change this to "find", and the Syntax for the find is same. Let's discuss that find, and let me start the parenthesis. Once I start the parenthesis, I got the synex: find text, the text which I wanted to find within text. I can give a text or I can give a column name; in fact I can give a major when I'm creating a major. Start position: the position from which I should start, and not found position: if I do not found what I wanted to return. I can also return a blank if need. I use this. You can see I'm not able to find any cities with "new", why? Because any "W new" is capital "new" inside the city. Start with the default position. Return zero if not found is returning me zero because any "W" is not available in any of them. So let's try "N" capital "ew". Now we will get the first three values as 1, 1, 1 because we are able to find out "new" on the first position. Okay, so this is how we use find. We will take a quick example of a major also. So I'll go here on my report view. I already create page where I use search. Let me call it "search and find now", and let me add a quick major. I'll click on the major table and I'll get a table tool because I clicked on the table this time, and inside that we have option for new major. I click on that and I'll quickly write down a major: "find city find new city", let's say, and we'll use "count rows", filter geography, geography, comma, find what I want to find "new". "New" should be in title case where I want to find it in geography City. Starting position: if not found zero, greater than zero. It should always be greater than zero. Same result, but if I make it "new" capital or I change anything, let not even this, I make "n" small, it will return all blank because I've used filter, and when filter doesn't find that value it's going to return a blank for that. So these are the quick examples of a new majure as well as a new column.
Now let's learn "contains string" function. "Contains string" is function which is not case-sensitive, means whatever you want it to search that's not going to be case-sensitive. It cannot search for card anyways. It's very similar to the functionality what search and find provides, it but actually it returns true and false; it doesn't return a position to you. So let me start a new column. I already clicked on a column, so in the column tool I have new column, and let me let me search "contain new". I'll use "contains string" within text. So first we have to give which within what text. I can give a column or I can give a text. I'll give "city" as a column, and what I want you to find out? I want you to find out "new". I'm going to give it in all caps to check whether it is case-sensitive or not. It is actually not case-sensitive as is given in the description. It's going to return true and false whether it finds it or not. It returns me true for first three cities where previously find and search for giving me 1, 1, 1 which is position. So we can can use whenever we need true false results. Let's take an example in the report view for major. So I'll go ahead and copy this major and try to simplify this. I'll create a new major. I'm in Major Tool, so I can use new major, and I'll now say "contains new", and here let's change it simply. Let me try to write down "contains string" first is within a string, so we need to give geography City "new". So what we have done is basically filter table geography and simply checked true and false here, and this is what we need in the filter. Every condition in the filter should return return a true and false, so this one satisfi that condition, so I don't need to check equal to true or false that I don't need. It's simply written true and false to me. In this manner you can create quick major and a new column on "contain string".
Let's check out function "contains string exact". Now "contain is string exact" is going to check for case sensitivity. The syntax is very similar to "contains string". So let me copy this "contains string" column. I clicked on a column, and if it has a formula it will start showing it in the formula bar. As I clicked on a new column I will also get a new column option. I can simply click on that and cop and create a new column. Let me paste this and let me call it "contain exact new", and let me change this to "contain string exact". So I removed "G", so it's starting suggesting me the syntax is very similar. Within string, find a string, returns through the string contains another string. "Contains string exact" is case-sensitive. It is case sensitive. So when I give "new" in capital it might not return return any true. Everything is false because "new" is not present. Any "W new" in capital is not present. Title case "new" is present in first three, so I'm changing that right now in my formula, making it a little bit bigger for you. Enter, and now I'm going to get true. Let me use this in the report view by creating a major. So I'll copy this "contains new" major, and because I clicked on a major I do have major tools available with me. Click on a new major to get a new major: "contains new contains new exact", and here instead of "contain string" we'll use "contain string exact". We'll keep it capital as of now, all "new" as all caps, and we'll not get any value. So now we will change it to title case. Press enter, and we get the values as three because there are three cities only which contain any "W" in title case. In this manner we can create major and column for "contains thing exact".
Now let's have a look at three more DAX function which is right, mid, and left. And to do that what I'm going to do is I will go to this table "date Auto". I'll going to create first a column, and what column I'm going to create here is basically create a date which is in ddmm and YYYY format. So I'll use "format" function, format date which is there in this table, comma, DD iy mm iy YYYY format. Now my objective here is to extract out date from this column and put it into date function. What I want to do is I want to use the date function. Date function require year, month, and date. I want to extract this, and during the extraction of this we will be able to use all three functions: left, right, and mid. So let's start again with a new column. I already clicked on a column, so column tools going to enable us or a new column. Me quickly click on new column, and in this new column I would like to create a new date. Again I'm creating a date, just giving a name "new date". I'll start with the date function. Now date function requires first what it require? Year. Where is the year here in this date? Here is last four characters of this, and to get the last four characters we use right. Right is the function which you're going to use. What we're going to take is going to take a text and number of characters. Returns the specific number of characters from the end of the we're returns from the end. How many characters I need from the end? I need from the end four characters. The four characters represent year. Now DAX is pretty flexible. Sometime when you return return text and it use it as a number, unless you create an error, it does do that autoc conversion. Now month, where is month lying here? So here in this string the month is lying in the middle. Let's check the number. So this is the first position, second position, third position. Third position doesn't have month number. Fourth and fifth position has the month number. I need four, comma five. Okay, or I need four and two characters. Let's look at the mid function which is going to help us out. So we need mid function here. Let's look at the syntax of mid function. It has three arguments. Is requires first argument is text in which we are giving a column. You can give a text also, means you could have given a hardcoded date here. Then the start position. Start position in our case is fourth character. It's not the third character. It's not starting with zero. It's the exact fourth character when you count from one, two, three, four, and then the number of characters. How many number of characters we need? So we need two characters. So we'll use State DD YYYY from the fourth. I need two character. It should return a month. Now I finally need day, and day is present as first two characters. And first two characters there is a function which can help us, that function is left. What is the syntax of left? Left function, the text we can give a column or a text, and number of characters we need. How many number of characters we need from the starting of the string? We mmdd YYYY, and there's a timestamp also. I can remove the timestamp. I clicked on the column. I can go to the format and I can choose a format I want. I can choose a short date. So in this manner you can use these three functions: right, mid, and left. Definitely you can use them into a measure also, and you will be able to create the required calculation using these.
One more thing which we can do with this, we can use the Left, Right function along with the sear function to create the first name and the last name. Now what we are going to do for that is we'll go to our geography table. So in the geography table there are only few cities which contains the PO names like New Orleans, new Las Vegas, and JY City. For only few cities where we have first name, last. What we'll do ins whenever I contain one should only show me first name. Whenever I have two it should show me first name and last name. So last name would be empty in case I have one word City. So let's take out the first name. What's the rule for the first name? So the first name should come till the place where we have the B as a character. So what we can do is we can use the left function. We use left and on the city column and till what place? First few characters we should go. We'll say search, and in the search we will say the find the position uh so the position of what? Position of space. The moment we get the space then within the text which is City, start position we are not going to mention. Now I'm not going to mention not find Value as zero because what would happen if I press not found value is zero? Let's understand this because when we don't find the space it's not going to give me the first name, that's what I don't want. Like in the New Ark I'm not getting any name, but I need the name because that's the first name. This is only name what we say in such case is we use one more function and we learn now a new function which gives me length of the text, and I'm going to use the length of the text. So what I'm saying here is in case you don't find it actually written the length. So what would happen? You will go till the last letter of that thing, and you are now getting that particular City where we only have the first name. So first name is all sorted. Now we need to work on the. So I want to use right. What is the text in the right? I want to give. I want to give the city, and I want to give the number of characters. So now number of characters is from the end, but when I use the search function that's going to give me the position from the starting, isn't it? So if I say space, comma space, within text City, starting position, and let's say zero is the not found position right now. What would happen? The space is the starting position is not going to work for me because space is at the fourth position. Is going to give me last four character. So what I need exactly? I need length minus the position of the space. So what happens when I do that? Now what happens? Because if I'm returning a zero or the city is where it has the for the cities where it doesn't have the space it's going to give me the last name also as first name which I don't want. So why don't we return length there of the city? What we are saying is we are going to return the length of the city in the search when we don't find anything. So it will take us to the last characters. So length minus the last character is again the length is zero. So let's see what happens in that. So the last name goes away. See, it's almost the similar search which we have used there. Now definitely because we want the last character so we use length. So from here we do and other thing what you could have done, you could have used mid starting from the space and use the mid and the length is number of characters what you need. But again that would have number of characters again you to find out using the length and the search. So right is the best choice in sear case. So this is just an implementation of, you know, search and right and left together. So these kind of combinations will keep on coming to you when you do your actual project. You can do similar kind of exercise in Majors also. This is combined version of two thing functions.
Let's understand the function "select columns". "Select columns" function can be used to create a calculated table with the column renames, and it can also be used as a table expression inside a major calculation. I clicked on a table, and inside the table tool I have this new table op option which I'm going to click, and I'll use "select columns". "Select columns". Now the most important thing which this select column does is it can select a set of columns. Me you can't filter the table vertically. You can reduce the number of columns which you want. So let's understand the syntax of "Select column". "Select column" takes a table and then it takes the pair of name expression, name expression, name expression, and it finally returns you to a table. So this name expression pair means one is you can rename the column. So basically you can have a name of a column and then you can give a column. You can give the same column multiple time. The name expression also means that you can give formulas for a column. So let's say you want to say A+B, A multiply by B, Cas which is statement or something that also you can do, means you will be able to perform low level calculation while you are writing down the expression in "select column", and "select column" is not going to group by or filter. It is just going to give you a table with the set of expression renamed as per your requirement. Now inside the table expression you can use filter if you want, or after the "select column" again you can use filter or summarize whatever you want. In this manner you can use "select column" for various purpose. So let's say I want to bring in table. Now I want to call "brand" with some some other name. Let's say I want to call "brand name" again. Let's say I want "brand" with some other name, "brand two", let's say "brand only". I can do that. Then I want Item ID. I can give a new name "item identifier", and I can use "item id". Now I selected three columns. Let's assume that I only need these three columns. So now I got the item table. My item table used to have 55 rows. I again got the 55 rows. See, it's not summarizing or it's not filtering here. "Select column" is not filtering. You can use filter inside the table expression. Instead of "item" you can use filter something there. You can use "calculate table" if needed, but whatever columns I'm getting I'm able to rename that. So what I would like to do now is I would like to add some expression here. I'm making it a little bit large so that you can see the table expression clearly. You would have remembered that some time back we added some calculated column in our item table. So I clicked on the item table, and if you look at this "group two", this is something which I wanted to add. There is a switch statement which is categorizing the category.
Into various groups and let me go back to the select column table calculated Table. And there, what I would like to do is now I would like to add another column which I would like to call as group. So I have given a name, and and now let me give the expression the same expression which I have given there. Now after giving that expression, let me come out and press enter. Am I able to get that? So as you can see, every role the calculation has been done and I able to get group one, group two, group three. So you can see that the category one is lying in the group one, but we don't have a category, but it is still calculated because it was part of the original table. So let's add the category to understand that. So just before that, now I am adding C category and the category column from item table. While I have given a table name in the table expression, so I might not require the table, but it is always better to use table and the column name, the fully qualified name. And now you will be able to see the category column. So you can see the category column and you can see that the category 2 is part of the group one. Category 5 is part of the group three. Now can I do some calculation like multiplication or something? Let's say I want to add, let's say item by brand. I want to do very simple stuff here. Is I want to multiply the item ID by brand ID for our reference purpose. Let's do that and let me enter now again, or I can press this commit button. And now you can see that the item ID and the brand IDs are getting multiplied. Actually the item identifier is one in this row and the brand ID would be 10 for the brand 10, so I'm getting a value 1 * by 10 is 10. So in this manner you can see that we are able to rename a set of columns, and we are also able to write down name expression name expression and enhance our calculated table at the same row level where the original table was and able to get the data. So still have the 55 rows, but we have the additional column in a new table using select columns.
Now sometime this helps. There are operation where you may be using in the same table or maybe we need to rename the column before we use it. And in such cases select column is pretty useful, especially when you do cross join or you use generate function and the two tables have the same column, then you can use select column to rename such columns. So in this manner you can use select column to create a table which is cut vertically. It can be combined with calculate table and filter to get a horizontally filtered table or the table which where the rows are also filtered. Here columns are filtered. Let's learn the next function which is summarize. The summarize function can be used to create a new calculated table where we can get the aggregated data. It is heavily used in measures to you know handle the grouped data, sometime to correct the grand totals, creating intermediate table which can be further used for analysis. So let's learn first of all how can we use summarize in a new calculated table. So let's understand what that function is. So first I'll go to table tool, new table. I want to create an aggregated. What I want in my aggregated table is I want the sum of items net sales item wise, brand wise, category wise, or let's say City wise. Take two different dimensions. So we would like to create brand wise net sales and gross Sal. How do we do that? So summarize it, we have a function summarized. What does summarize function does? First it takes an table, then it takes the group Group by expression. The group by expression doesn't require a rename. You cannot do a rename and then name and the expression means expression means the some, the column where we are going to use some kind of aggregation. For that you can use an rename again in the table expression. You can use add columns, select columns, calculated table, filter, whatever you want, you can do that. So here what I want is I want to summarize the sales data. What I'm going to use, I'm going to use a center table sales table, because if I use the dimension table I might not get an access to the many side of the table. I'm trying to use a table which is fact, which is a central container and it is related with tables like item and customer. And as you can see it is started showing that. So from geography I would like to bring in state. So I would like to summarize my data on state, item, brand, State and brand, and then I want to calculate net. Net is already a measure. Let me call it as and I can rename. I usually what I do whenever I create some columns by myself, I usually rename that underscore to differentiate. And I can use a net major. Now I'm using net major, it doesn't mean that it's going to filter with my slices value. It's not going to change. It's going to be the static value. And if there is some row and let's use the major gross, then can I on the Fly do a sum of quantity or something? So let's try underscore QT y, comma sum of sales quantity. I want to do on the Fly sum. And now I want to create this table. So I'm getting 442 rows and I'm getting these values. So for New York I have net quantity as 24,000 approximately, gross 29,000 and quantity as 84. It has no impact of filters and slicer and this is true with all the tables. So let me go here in the filter region here. Let me use something on all pages, isn't it? So let's go to a name and basic filtering customer one. It's going to filter on all the page customer one, but if I go to the table view there's no change. Still you can see the value is same 24,000, 29,000 and 84. There is no difference. Calulated column has no difference when a filter or a slicer get applied on the page. It has no relationship. It is precalculated. Even the measures if you are using in such tables get calculated and evaluated at the load time, so they are static in nature. Calculated table and columns are static in nature, so don't expect their data to change using filters and slicer. As of now that is not possible. So we have used summarize here in a calculated table. There could be n number of things you can do with using this. You can have some permutation combination with other calculated table functions like calculate table filter Etc and it could be used in major and major we can can drive few things. So we will go ahead and take a major case little bit later. Let us learn a set function which is Union. And for that what I wanted to do is I want you to bring in a new file from the GitHub and that is the file which we are going to use for few more operations set operations. So the file name is upend and summarize Group by and we are going to use in few more operation. As I said earlier, we're going to use this in few more operations. I'll right click on the raw copy link and as we have done in the past we will go ahead and use that inside our powerbi get data web and inside the web you going to give this URL. Click on okay. It should suggest us two table data one and data two. Data 1 and data two two Excel sheets are there. I'm taking both of them and right now I don't want to do any kind of transformation of data, so I'll directly load these tables. The tables are loaded now. I want to create a union of these two tables whatever data they have. So data one has three rows item one, item two, item three and data two has item one, item two and item four okay and they have different quantities. So because they have different data I want a union all. Usually the Dex function Union does a union all. So how would we do that? We want a new table again. Union function can be used to create a new calculated table as well as it can be used in measures as per requirement. And in the new table let me go ahead and do rename as Union table and we'll call Union table one which is data 1, comma data 2. So we got a union where all the values have been just added up. So this is how you can use Union function and we will see more use case of this little bit later.
Let us now learn set function intersect. It can be used to calculate calculated table and it can also be used in Majors. I'll go to the table view. I have two table data one which is having item one, two and three with some values and table two which is again having item one and two and also a new item item four which is having a value eight and these values are not matching. Items are matching but the values are not. I'm doing intersect operation which gives me common values. Is it going to give me anything? Let's go ahead and check it out. So I'll click on any of the table and go ahead and do intersect operation under the home table. I can see new table. I'll click on the new table and I'm creating a new table here, but this can also be used inside the major. I'm creating a new datable data 4. Why not data 3? Why data 4? I'll let you know. Intersect left table and right table only two arguments it can take. So let's give a table which is data one and the second table right table data two. Let's see what these two tables have common. There's nothing common. Zero rows are returning. How do I check whether it's going to work or not? So let me do one thing very one quick thing. Right click on this table data one and copy the table, then go to enter data under the Home tab. Once it opens up paste it. You will get the same table. It just got duplicated. I'm going to change the value for item three and I'm going to call it data 3. Now you got your data 3 and press enter or I can press load button. Now I got a table data 3 which is having something in common with data 1. The first two rows of the data one is common with the first two rows of data three. Data 1 and data 3 has two rows common. Now I'll go to data 4 and instead of data 2 I'll use data 3 and press enter and as you can see I got a table item one as one, item two as two. These are the exact common set of values. Please remember the complete row set need to match. We also have functions like distinct values and summarize which can help us to get distinct values for a single column or summarize for multiple columns and that can also be used in such cases to create a combination of a column set before we use intersect. So as per your need you can can use it in a table or in a measure. Let us learn the set function minus. Don't have a minus here. We have except and what the accept does is something which is present in a table and not present in the second table. So something which is present in a not present in B. I need that kind of data. Now to do that what we are going to choose here is data one which contains one item one, 2 and three with three item three having value three. Data table three where item three has a little bit different value. Now let's start by creating a new table. As of now we can see new table option under the Home tab. Let's click on that. This table can be named as except. Let's use the function except. Except requir two tables, left table and the right table and it's going to give the data which is present in left table which is not present in the right table. Returns the row of the left hand side which is not present in the right hand side table. This can be used for calculated table table or measures. Take an example later how to use this in a measure. So let's use the data one as a left table and data three as the right table. We should get the item three row with the value three because that is the one which was there in data 1 table which was not present in data 3 table. What happens when I change the position? Now I should get the item three but with the value six because that is the row which is present in data 3 but not present in data one. One in this manner you can use accept function. This can also be used to find out sometime when you come across the cases when you need a major something which is present in particular situation and not present in particular situations. In such cases you can use that. Accept function will help in measures Also. Let's learn distinct function and values function. There are two functions. Let's learn how they behave what they give us. So I'll go to the table View and inside the table view I have this item table and in this item table I have branch and the branch are only 13 but they're repeating in all rows 55 rows. Similarly categories are only five repeating in all. I want to know what are the distinct values I have for the brand and item and I may want to repeat that. So let's go ahead and try that out. So I'll go ahead and create a new table and let me give it as a name as Brands which is nothing but distinct item brand. It's give me distinct item Brands. Can it give me distinct of a table also? Yes it can give, but for that we need a table with repeating values. We'll take that example, but before that let's look at one more function which is values. Again from the Home tab we'll go to the new table function and create categories category table and we'll use values item category. It can take a table or a column name. That's one of the two things it can take. When a column name is given it return returns a single column table with unique values. When a table name is given it Returns the table name with the same column. We have functions can give us distinct values. You use the column example. Can I do with a table? I have two tables data one which is having two rows which is common with the table data three. What I want to do here is I want to see can I combine them Union? I have was able to do a union of those and can I get a distinct? So let's try to have a union distinct table which is actually the SQL Union. Can I have the SQL Union? Let's go to a new table again from the Home tab this time and we want the union the SQL Union which is not Union all. Usually the Dex Union is Union all. So we'll say Union of data one and data three. What is giving us? It's giving us the data which the duplicate rows. Let's see can we use the function distinct and the moment we give distinct what does distinct function con take? Distinct function so distinct can take column name or table expression. Return one column table that contains the distinct values in a column for a column argument or multiple column with distinct unit combination of values for a table expression argument. Table expression argument we want to give Union data 1 and data 3. Let's see what happens. So now we have item one and item two repetition on item three is having one value as three and one value as six and that is why both of them are coming. So with the distinct we are able to do it. Can we also do it using values? Let's do one thing. Let me tell you one quick thing. I can make it this one as a comment copy so we remember both and use values here now okay. Values function except a column reference expression or a table expression as argument one okay. It's not taking this one. Can it take already existing table? Let's do one thing. So we have Union equal and let me make it as only Union the union SQL table. We have still have the duplicates. Now let's create one more new table. We have one physical table and now we are going to use that. Another physical table is distinct SQL as values Union equal table. So understand this thing. When we use the table expression it doesn't give us the unique values. So first you are not able to use values with a variable table and second it's not going to give you distinct values for a table. So for a table distinct values we have to use distinct but for a single column we can still use values function. For a table it's not going to do it. It has a different purpose. So in this manner you can use values and distinct function as per your requirement and you have learned some of the differences. We have another function which can group the values and that is known as Group by. We will learn a use case where Group by is going to behave better than summarized, but to do this use case let me tell you what use case I want. So in this use case what I want to do is I want to create a new table using data 1 and data 2 and without creating a third variable using that inside a variable I want to summarize the data. I want to sum the values. So as you can see they have some common rows with items is item one, item two are common in those. So I want to summarize that value. I don't want that to repeat. Union function will repeat it. It's not going to aggregate that. Let me click and create a new table and the first time I'm going to attempt it with suiz summarize Group by. So let me create a variable where underscore Tab and this is a very simple table which I'm going to create using Union data van. First argument it can take multiple tables so data one and data two. Only two arguments I want to give. As you can see in the syntax I can give multiple tables but I'm only giving two tables here. I have two tables then shift enter. Return what I want in return is summarize. How many columns I have? Two, two columns isn't it? So what is my variable table and from that table one column is Group by which is item. So I can use item, comma I want the sum so underscore sum of what? Sum of underscore I can't use sum so I need to use sumx underscore Tab and comma values column and let me. I got a sum column. I I got a group by column and let me press enter. What are you observing here? It is actually 22. It is actually the sum of the complete column. This table in the sumx is not taking the row context. It's taking it as a complete column. The current row context is not available while I'm doing the summarizes some same as creating a calculated column. It takes the complete value of the column, but that's what I don't want. What should I do in such case? So let's copy this code and create one more table again under the Home tab. New table is appearing. I'll click on that and let me paste this. So this is Group by Group by. So again the table with Union but let's start with a different function in the return and the function which we are going to use is Group by. What does Group by takes? It takes a table expression, Group by column names, name and expression for expression. So whatever number of Expressions you have you need to use a name for all such expression. You need to rename the expression where you going to have the aggregate data. Same is true for summarize also. What is our table name? Underscore tab gr by the column name is item. Want Group by item, comma I want to do sum underscore sum, comma sumx the function I want to use and here instead of table name I'll use current group function and then I'll use the value column and let me close this and try out and now you can see the item data is grouped properly because of this current group functionality available with the group by function which allows us to group the data which is applicable for the current Group by in the context. So in this manner you have observed there is a difference between summarize function and the group by function. Let's now learn a function which is known as generate series. Generate series function can generate a table with a sequence of numbers. So let me click on any of the table and from the table tool I'll click on new table. I would like to generate the numbers sequences from let's
Say 1 to 100. The function is generate series. What is the start value? The start value is one. I can give one, I can give zero also. The end value is 100, and increment by one. So, in this manner, I'm able to get a table which is generating sequences for me, and it is giving me 1 to 100.
Now, in case you want to generate an odd number series, you can just give it two here because it's starting from one; it will generate an odd number series. It will have 50 values only because till 100 we have 50 only. Now, if I want an even number, I can either start from zero or two, so that will create an even number series.
Now let me tell you, I can create a date table also. Along with that, let me use generate series. The first argument is the start value. The second argument—let me generate it for 365 days—and the third argument as one. Again, it's going to create for 365 days. I'll go and use now add columns. Now add columns is only getting what—the values column with 365 values, comma name—I'm going to create a column which is known as date. And what I'm going to do there is a beauty about the DAX date. There's a beautiful thing which we have learned about DAX date: that we can simply add the numbers by using the plus sign, and it will keep on giving us the dates added by that number. So let me start with 2018, comma 01, comma 01, and let me add plus. Now the generate series is returning me the value column, which now I can use in this add column expression after the name, and let me press enter. And as you can see, we're getting the dates generated. But there's a problem: we are not getting the first one because it's going to add the one also from zero to 364 days. Now we got all the dates what we need.
In this manner, you can use the generate series function. You can use it in a table; you can also use it in a measure. There could be use cases where you need to generate a sequence inside a measure, and that is where you can use the generate series function to generate a sequence of numbers, and that can be further used through some complex calculations.
Let's learn two more DAX functions: generate and cross join. Both the functions can generate a table which can be used in a calculated table or a measure, which basically do the Cartesian product. It is going to create the complete combination of the values. To take this first example for generate function, what I'm going to do is let me show you the item table. Now the item table has 13 brands and five categories, so the total combination is 65, but we are getting 55 rows here. It means there are some combinations which are missing. So first of all, I want to generate all those combinations, and the second thing could be that what is the combination that is missing. Out of these are the things which we can do. So let's go ahead and find that out. For that, what I'm going to do is I'm going to create a new table, and for that I'll go to table tools and new table. And how do I create that distinct combination of values? So for that, I need to use the distinct function also. So let me use the generate function first of all. What does the generate function do? The generate function takes table one and table two. The second table expression will be evaluated for each row of the first table, returning the cross join of the first table with these results. Now this evaluated for each row is a real big important; for that we have to take a separate use case, but we will take distinct item brand as the first table, and I could have taken a bigger table, but because I want to create that combination, I'm taking a single column table, but definitely you can have a table which is having more than one column; it can also work out. And then we will use item category; we will use distinct item category as the second table. So now we have got 65 rows, as you can see. It means these are the possible combinations. Now how do we find out what is the missing combination? We have learned one function, except. Now the except function gives us something which is present in A, not in B. So how do I get the distinct values? I can select all the values, or I can do a very simple thing: I can go and use the summarize function. What does the summarize function take? It takes a table as an argument first of all, and then we can give all the group by columns, and then the name and the expression for the aggregated column. But here we only need the group by column, that is item brand and item category. So these are the distinct combinations which is present with us. So now you can see there are 29 such combinations are missing. So basically, it is not that 55 rows has all distinct combinations; there are 29 such combinations which were missing in this case. And let's sort it on a particular category, sort ascending. So for category one, it is saying there is no brand 12 and 2. So let's go to the item table and validate that. So we go to the item table, we select category one, and you can see there is no brand two and 12 here. It means we are getting the correct results. We have done this using generate, so we see what generate does and what it can do. The same operation can also be done using cross join. So we'll again create a new table; the table tool is visible, so let's utilize the new table under that, and this new table would be cross join. Again, we can use this into our measures also by generating some tables. So cross join—what cross join requires—returns a table that is a cross join with the specified tables. Here you can have multiple sets of tables; it returns the table that is in cross join with the specified tables. Now it is not talking about the row; that's very important. Okay, so we will use distinct item brand, comma distinct item categories, and we have got the distinct 65 combinations again. Again, I can use that except code to find out what is the combination which is missing. So this is a Cartesian product which has happened: 13 distinct values, five distinct values; the Cartesian product has been done by cross join. Now we'll complete that step and then discuss what is the difference. Except, and what I've done is I copied a part of it; let me use that again. Summarize item, item brand, and category is going to give me distinct combinations which I have done just a minute back. I'm bringing in that, and I should get 29 rows; same 29 rows I'm expecting here. So it means we are able to do cross join; we are able to do summarize to get the distinct value of more than one column, and then we are able to find out what is missing in a particular combination. The same could have been done in a measure.
Now what's the difference between the two? When should I use cross join, and when should I use generate? Whenever you need a filtering mechanism, you should prefer generate, and the reason for that is that generate can work on the row value. Cross join is not. So let's take a new file, and I have loaded a new file for this purpose. So let me go ahead and bring in one file. So we'll use this file, cross join versus generate. It is employee data. You could have used the employee file, but I created a smaller version of that so that we can easily use it and understand that. So let me click on that; we'll right-click on the raw copy link, go back to the Power BI, and in Power BI we'll go to the Home tab, get data, web, paste the URL, click on okay. One Excel sheet with the name employee; I'll press the load button. The employee table has been loaded here. So what I basically want is basically I have a start date and end date, and I want to generate all the dates between these: 1st to 15th February, 1st January to 31st January, 1st January to 31st January, 15th January to 31st January. These are the dates; I want to generate all the dates between that. So let me try out this thing first using generate. Home tab, new table visible, click on that. What we need to do here is basically employee days dates one, employee dates one. What we generate—generate function—what is the first table? Very simple, employee table. What the second table? The second table is I need a calendar; I need to generate the dates between the start date and end date. Can I get the start date of the employee table? Seems like I'm getting the end date of the employee table; seems like I'm getting that. And let me, after doing this, let me try; let me press enter. And as you can see the data here, for the employee one we're getting all the dates in January also; we are getting dates till the 15th of February. But for employee two, the data is ending on January. For employee three, it is just 15 days of data; only those dates are getting generated. Now how to do the same thing in the cross join? Okay, let's try again. Click on the new table under the Home tab; it is still visible. Let's call this table as employ date two. Cross join employee table, comma calendar. I try to get start date; I'm not getting any suggestion, so maybe I'll forcefully write down. So I copied that code at that time; it is showing me an error, so seems like it's not going to give me, and yes, I don't have a row context available, so I'm not able to use. So what I'm going to do here is I'll use Min of employee start date, and I'm taking the complete table column now, okay, and Max of employee end date. What it is doing is basically giving me the minimum of the start date and the maximum of the end date, and because of that, let me sort it on the employees. What's happening here is look at the employee second; you will see the employee second has the data in February also. Employee three is having the January data from 1st January and having the data in February also, which is not correct. In such cases, what we need to do once we get this, and assuming you don't have a common column name, otherwise you have to use the select columns; you have to use filter here. Now the date column, calendar, generate a date column, so we have a date column is greater than and equal to the start date, and date is less than and equal to and date. The dates which is available in this table, you're going to use a filter function, and the rows have reduced from 130 plus to 294. And in this case, you will see that the employ two is no more getting data in February; the same is true for employee three, very limited data. So you've seen that cross join is going to create a much larger data set in such a case. And think about you have a very large date range; it can explore the data, and then we filter it, which is really not effective. And think about that we may have to do this as a measure, and in case of a measure what happens is uh we typically use a disjoint table, and using the disjoint table join also we can actually for such filter, we may or may not always use generate and cross join used there, but yes, as per requirement, and use them. So what I've done that when I was doing all those table operations, I actually saved the file as N2 and 3, and I have kept that file aside now, and I came back to N2 and 4 for the rest of our operations which are typically related to measures, and now what we wanted to do, we want to learn a few more measures, and for that we need the help of some of these table calculations, and that's why we learned. So now what we are going to learn is some of the use cases where we need to use summarize and values. They can help us to change the level of detail calculation, like some of averages or average of sums. So basically, what happens, you do an operation till a particular level, and after that you change the aggregation. So it was doing sum, and then I do the average. Same way, sometimes what happens is we are using a filter context of visual row, and I'll give you an example of what we mean by use context. We reuse a filter context in the calculation, and the grand total is not going to be correct in such a case. Also, in such cases, we can use summarize and value. Sometimes the way I'm telling you may not work; in such cases, what you have to do is you have to basically go ahead and create a measure first and then create another measure on top of that to make it work. So let's jump onto the first use case where we are going to do it. I want to create an average of—so let me create a matrix visual—and in this matrix visual I'm going to bring in from the geography table, state and city. I'm also going to bring in a net measure as a value. Let me expand it. Very simple, you have certain cities for which the values is getting aggregated, and that the same sum is shown here. But I don't want the sum at the state level; I want an average. How I'm going to do that? So let me start with a new measure, and this new measure is going to be average of city net. This city, I want to do some post that I want to do average. What I have to do here is basically AVERAGEX. I can use values or summarize; let me use values as of now to begin with. Values, then let's use geography City. Till this level you have to do whatever aggregation I'm going to do in the expression net, and then I'll complete this code, and let me bring in this new measure. As you can observe here, the value is no more a sum; it is an average. I would like to take one more example here. Now we have a measure known as gross amount, isn't it? So let me do one thing: let me first create a measure with the help of values only, and let me call it as gross. Average gross, same calculation what I've done for net, and you can see the average is happening. I would like to do the same calculation now, but with the help of a column where I want to aggregate it into the expression part of the AVERAGEX function. So let me create a new measure again. I'm going to take help from the measure tool which is visible right now. Let me paste this gross calculation and make it gross fun, and here instead of gross I'll use SUM of sales gross amount. Very simple, instead of measure I am going to use the sum of gross amount, expecting the same result. Pay attention; the result is not the same, not same as this one. And let me bring in Gross for your reference, and this is the behavior of the expression function which I want you to note down. And to correct this behavior, let's use CALCULATE inside this calculation in the expression. If you need to do an aggregation, if you are giving a table expression, table expression, and you are using aggregation on the column, then you have to use CALCULATE in the expression; you cannot do it without that. Let me do it right now, and now you can see the values are matching. That's great. Can we do the similar kind of calculation with summarize? Because values will allow us only one; summarize can allow us multiple. So let's say I want after two the average should happen, or after three average should happen, or the calculations which are done which need a grand total, subtotal correction might require multiple columns, then what should I do? So now let's try the same thing. Can we do it using the summarized function? We have already used the value function. Let me do one; go ahead and copy one of the calculates. I'll copy this gross calculation, and I'll modify this. Just for my reference, I'm copying it, and two, and let's put this into the commands and try to replicate the same. The first one we are going to do is AVERAGEX, summarize, taes. This is the center table, geography City, till City. I need the sum, and then I simply use the gross measure, and let me check the calculation out, and as you can see, and let me move the gross maybe at the start along with the net. Now you can see this calculation is the same as this one. So mean summarize can also help us, and summarize can take multiple columns. You give the center table; the reason I given the center table is that if you are working across two tables like item and geography, then still you will be able to do such a calculation. Let's say you need it after two columns, so there is a level of detail which you have, you know, used it, and post that you have done it, and it is not that if even if I go, let's say one step ahead, and let's look at this; let me go up one level. Now in this case, right now there is no City present in the calculation; the level of detail has been included to take the average. So if some of you wanted to have a level of detail include, this is something how you do level of detail include. You have learned remove filters; that is exclude. Now this is include. Now let's play around further with this. So what I'm going to do here is can I do a sum of gross amount here, and is it going to be a little bit different? So we say SUM of sales gross. Just like values, do I need to use the calculate function, or summarize can do a better job for me? No, I need to use CALCULATE. So let me use CALCULATE here, and I'm not creating multiple measures here for your reference; you can go ahead and create it. This is one, but yes, I'm going to do one more version of this one. Let me copy this, and let me create a new measure of another version which I can create with summarizes. Actually, summarize can also include a calculation inside the table. So we have the group by columns, and after that the expression says that you can have name and expression here. What does that mean for us? You can have underscore one, or I can give underscore gross for your reference and name, and here I'm not using CALCULATE; let me use SUM, and here uh this SUM is ending, this is uh summarize ending, comma underscore gross, and I knowingly give these whenever I use such variables or such calculated column which is inside the table expression or as a variable or a where I usually give them underscore so that you are able to differentiate that I'm doing something different, and let me do this is two is already available; let me rename it and press enter. Let me add it to the visualization, and our calculation remains the same what we wanted. In this manner, you can use summarize also to get these average of sums; you can do the same thing with sum of averages, or when you want to use include level of details, this is what you can do. So another example which I wanted to do here is basically where we use the filter context of visual row, and our grand totals are not correct, and we wanted to correct. Again, values and summaries, depending on the requirement, can be used. Sometimes they can be used just like what example I've given here, and sometimes you may have to use the measure inside another measure where you use values and summarize. So you begin—let me rename this as average of sum—and let's begin a new tab, and this time what I'm going to do here is let me bring in brand from item, and let me create something which uses the filter context of visual row. I'll bring in that, create a table visual. So if you created a visual and you want to change it, just click on that visual and click on another visual type inside the insert or inside the visualization pane, and you will get that kind of visual. Now I want to create a visual which uses context. And how do you use context? This is how you use the context, because after some time we will have some time intelligence measures which is also going to use that. So I want SUM of brand one, and I'm not going to use filter here; I will use IF, MAX of item brand. Now this MAX of item brand—what MAX is going to take in a row, see—in the row brand eight itself is available. Let's say there is a brand eight available, and I'm using category, so the row only contains brand eight, and then I'm using category, then it can bring the within brand eight whatever is maximum category is going to bring in that, but here brand eight itself is present; the MAX of brand eight.
What it is actually? It is brand 8 in the first row. So in this row, it is going to be brand 8, the brand 13; that's the only value available. Yeah, if I use category, definitely there are more values available. Then it can take a Max, and I'll call it as it is equal to Brand one, what value I want to return? Net; otherwise, I don't want to return a value. Let me try this out. I got a major tons of major. Now we have—you see the value for the brand one is correct, but there's no grand total here, and this is what we call the calculations error because of filter context. Context, have you used? Now this is one example; you may have many other such calculations where context is causing your grand total either not to appear or to appear wrong. Because remember the grand totals are calculated again. When you calculated the grand total again, there was no item brand available, and when the item brand is not available, you get a blank value. How do we correct that? So let's try with SUX values, item brand. If calculation did not work out, did not work out, let's use CALCULATE. The moment we added the CALCULATE, the results have started coming out. So as you are aware that when you use CALCULATE, it is going to appear. Let me remove the CALCULATOR and showcase you again. Whenever you are doing some kind of a calculation inside the Aggregates, make sure the CALCULATE is used, and once you use the CALCULATE, you will get your calculation. And you know the alternative is SUMMARIZE, and which you can also use to correct such calculations. So we have learned how can we use SUMMARIZE and VALUES to get include level of details and how can we use it to correct our grand totals. Let me just copy paste for your reference and add SUMMARIZE here so that you have an example to refer when I share these files with you. We'll use a SUMMARIZE sales, item brand, and this is sum of brand one, though I'm calling it brand two. So we have both the measures available with help from VALUES and SUMMARIZE. We continue with one more use case where we can use SUIZ and VALUES, and the place where we need is basically when we need to count the distinct values B. So how do we get the distinct count of anything? So in the sales table, items are basically made—not going to be more than—so how many distinct items I have in my item? Basically, what I can do here is I can bring in item here, and I can use a build a visual Pane and change its aggregation. I will get a 55; is the count I'm getting. There's a function DISTINCTCOUNT; I can use. So let me try to create a major first. Major is this count, and we use the function DISTINCTCOUNT sales item id. Let me bring it here. This is 55. On a larger data, the DISTINCTCOUNT might not give you the desired performance. I'll tell you a couple of ways which could give you a little bit better distinct count. We are going to use again in this DISTINCTCOUNT. I'm not going to use function DISTINCT; what I'm going to use, I'll use COUNROWS VALUES. Now single column I can use VALUES; we have learned that in the past. Get the distinct values; you can use VALUES. Let me bring in here, get it. Okay, so you're getting the same values. Now let's learn one more way which which you can actually use on multiple columns. Somebody asks you, what is the distinct combination of city and item you have in the—how do you do that? And in fact, somebody can ask that brand and state combination. How do we do that? What we are going to do here is we are going to use SUMMARIZE. So first let me give you this one listing count of item only, and then we will create a little complex case. So here we got this. Now we would like to know the brand and the state combination. Now state is also not at the role level, and brand is also not at the role level. What is that distinct combination present with us for that? Now let's go ahead and try that out, and this time let me explain you—I quickly changed. In the case of SUMMARIZE, we have done a few more examples already. Now this time what I'm going to do is let me explain you the complete calculation. COUNROWS, let me use COUNROWS; this can also be used when you have a visualization with few group buys and few Majors. You can take the complete combination of those majors and group buys in the SUMMARIZE and can count it. So COUNROWS SUMMARIZE, what SUMMARIZE needs? Table, so central table, I'm going to give geography state; I'm going to take and from item I'm going to take brand. Remember the combination is not available in the say table; it is available in the related table, and I'm bringing in the count for those. DISTINCTCOUNT is not going to work alone; VALUES cannot help me out, so SUMMARIZE can help in such cases. So you can get distinct count counts using SUMMARIZE function and COUNROWS. Let us now learn how can we get percentage of total. We start a new visual. Let me create a matrix visual first of all, and in this Matrix visual I would like to bring in state and city from geography table. So state, city, and my favorite major. Bring city under the state. Now when you do that, when you go to this major and right click, you see an option percentage of grand total, percentage of row total, percentage of column total. Let's look what is percentage of GR total. Let's look at the other option. Right click, show value as percentage of column total. No difference; again it is 100%; no value is percentage of—there's no row total right now; there is a no row, so 100%. So basically they are just giving me percentage of grand total. So now let me go ahead and show show values. But what happens sometime? I might require certain calculation where I actually need percentage. How do I do that? We have learned few functions in the past, and they are going to help us out. CALCULATE percent of DT net, grand total of net. I want to use the DIVIDE function because I want to divide the current calculation by the total grand total. I'll tell you how to get the grand total. So DIVIDE functions make sure that divide by 0 is handle. Okay, if to divide by 0. So net, what is available in the current—now I need a grand total. The grand total should violate or should not have any filter consideration, and to do that we have something. First of all, I'll use CALCULATE net. Now I can use ALL or ALLSELECTED. Now if you want to honor the filters, use ALLSELECTED; you should—don't even want to the filter context, use ALL. I want to use ALLSELECTED. Let me not give any table name or it independent of the tables. So typically it will apply on your C. You will say it was showing 5% something because when you use percentage basically right now—a row—and to convert to the percentage you click on this, you will get the percentage, and now you are saying I need subtotal. How do I get for subtotal? Alaska it would be like 100% because Alaska only have one. Arizona has more. A couple of ways. Let start with first way. So the first way which I'm going to use here in—I'm going to use DIVIDE, and I'll call it ST subtotal one, and there are few ways. So first way is in the second calculator which is the subtotal which I want; I can use REMOVEFILTERS of city. Now there are only two levels, so I can say REMOVEFILTERS of City geography City. What happens when I remove the filter of geography City or when I use ALL geography City? TH will be removed from the context. So this is exclude level of details; I mean excluding a level of detail. Again, I need to make it as a percentage, and as you can see now this is 100%, this is 100%—only one city and this combination is 100%, and definitely at a state level we are going to have 100%. So this is one way. So we have excluded the—there is one more way which we can use for that. We'll go a little bit more changes here. Again the half of the formula will remain same. So the first part, the role remains same; the CALCULATE remains same. Here what I'm going to do is FILTER ALL ALLSELECTED geography. I'm going to bring in geography table, and then I'll say geography state. I'm trying to bring in the filter context of visual row. Geography State equals to the MAX of geography state. I'm trying to bring in the filter context of visual row here. Whatever state is in the context, that only should be considered as a filter. You take the complete geography table; ignore everything on the geography table but state is equal to Max space. So whatever state is there in the row, that is the only thing you to consider. I calculated another subtotal, and let me go ahead and make it as a percentage column, and you will see similar results. A little bit different approach, but what we have there done here is filtering the complete geography table for the row. So I considered the complete geography table for every row. Filter is applied; filter context of visual row been ignored because of that—on the context has been ignored—but we are saying the geography state in this complete table should be equal to the MAX of geography State, and what is this MAX of geography State? The state which is available in this particular Row. In this row, though I'm seeing City, but I'm Arizona is the state present here in the row context. So geography State complete table, I'm filtering for the current date, and that's how it is getting calculated, and we got the percentage of subtotal. In this manner, you can calculate percentage of up total. Let's discuss how can we create a rank. Now rank, we might need as a major; we might need as a column. Now we have few functions to do rank. We have RANKX, only RANK, and RANK RANK.EQ; there is function for that all. Now the function which we are going to discuss right now is RANKX, and we are going to discuss the RANK function later when we will discuss the functions which are very similar to SQL window fun. They are not same as SQL window function, but in few aspect they are very similar to that. So when we are going to discuss, that's where we are going to discuss the RAM function. First of all, let me go ahead to my table View, and in the date table I would like to create a rank. This rank would be used later when we will do the time intelligence. What I want to do here is I have this column Week start date. I want to create a rank on Week start date, and the reason for that is typically whenever you want to do time intelligence, if we don't have the extended time intelligence function, we actually use the rank function. Start of the week is one column on which I want to create a rank. I want to create a new rank column. Let me click on new column. Column tools is visible because I already clicked on a column, and let me use this Week start date column and create a rank. So I'll use—I'll give the name as Peak rank. Make it a little bit bigger so that you can see it. RANK, and you can see RANK.EQ, RANKX, and RANK three functions are there. I'm going to use RANKX. Now the RANKX function have few arguments which are required. The first argument is table. In case of column, it's going to be a table, or you can use FILTER function to return return a table which can restrict it. When we create like rank subcategory rank, if you want to create, you can have use the FILTER function. Expression, this is going to be our column. Third, we are going to leave. Fourth is order by; default it is descending. RANKX is by default descending, and ties is Skip, and dens by default is Skip. I'll explain you the meaning of Skip and dense in a moment. So we're going to use dense and Skip here one by one, and I'll explain the meaning. So let me showcase you. So I'll start with RANKX. Table name is date table, and I'm creating it as in a column, not adding to the script. We can add it to the script later, and then the column I'm going to use is Week start date, and I'll leave it as only two arguments I'm supplying right, and let me do one thing. Let me sort the dates on ascending order. We understand the meaning of ascending, and let me close date. We have a pretty big date skpt. Let me close that. Now let's look at it. So what's happening here? Definitely we are—why we are getting the highest rank first of all because it's a descending Rank. By default, we actually wanted ascending rank. So whenever we create a rank for the date column, we actually need ascending rank. Second, I opened all the distinct values, and you can see the rank has jumped. This is because it is a skip rank. What happens in case of skip rank? Let's understand this. Let me sort it ascending here. So for 7 days I have this rank. So the next rank is not two; it's eight. So it's a skip. The ranks which are actually—they repeating. If it is one one, then next is three; it's a skip. If it is one one, and next is two, then it is ten. So two things I need to change here is first I need the rank as ascending rank. So I need to give an argument; by default it is descending, and ties. We know by default it is Skip, so I need to create a dense Rank, and let me press. Now you can see on my calendar the minimum date is having rank one, and in spite of rank repeating twice, I don't have the rank as three; I still have it as two. Dense rank is a continuous rank; the rank numbers will be one to three in spite of repetition. That is what we call dense rank. So we have created a dense rank here, and we have created ascending. So RANKX function is something we have used to create a new column. Now let's go ahead and create a rank magic. So I'll add a new page for that. So let me create a visual brand, the table visual. I'm bringing in brand and net, converting it to table. I want to create rank. Already it is sort in descending. I want to create a rank on the same order. What I can do here is basically new major. I'll click on new major, and I'll call it RANK net. I'm going to use RANKX ALLSELECTED. Now what is the difference between ALL and ALLSELECTED? I'll showcase you in in a short file. ALLSELECTED item bran and net. Now I can give the other argument. So I can have in the table I need to have ALLSELECTED ALL ALLEXCEPT something I need here. Expression here need to be major values. We are going to leave order. I'm going to use descending because mostly we all to create descending Rank, and ties I'm going to use Den here. So I can leave any argument after this one. Descending by default it is descending, so I could have skipped that and den. So it's giving you r 1 2 3 4 5. What's the difference between ALL and ALLSELECTED? For that let me do one thing. Let me also bring in a slicer on brand, and let me build it as a multi-select and show. I'll do select all. As you can see that the moment I am removing something, the rank is getting adjusted. If you see now the rank is still 1 2 3 4 5 6 7 8 9 10. This is because ALLSELECTED; it is considering only the data on which the rank is getting created. But if you don't want that, you say no, no. Even though I remove the data from my context, I still want my rank to honor the initial data, then I can use ALL. Now you can see that the rank is having jumps. So we have number six; this is missing because we have unselected that. We have number nine which is missing. Okay, we have number three which is also missing. So this is how ALL work. Now let's come to a really interesting feature of the rank, and let me explain you. For that first of all, I'm going to bring from the brand table the brand ID into the visualization, and let me enable the build a visual for that. I right on the right hand side; there was an option. I enabled that, and I'm going to bring the brand ID. Why did all the rank became one? For reason for that is—and to understand that reason, let's change it little bit. Let me remove brand ID, and let me bring in actually category, and then you will be able to understand better. Let me sort first on category shift and sort on rank. Now you can see inside the category all the ranks are for the brand. So the category is is acting as a partition, and inside that we are getting the rank. So the rank get redistributed or partition on the column which is not present in the rank measure. When I created my measure, whatever columns are not present, if they are used in the visualization, the rank will redistribute inside that, you know, partition itself into that. And because of the same reason, because brand ID and brand are at the same level. Now category has different different brand, but where bring in now again the brand ID. Each brand ID has only having one brand, and that is why the rank is coming as one one one one. Then how do we handle such scenario? One of the easiest ways, and because they're belonging from one table, you can simply bring in brand ID also inside this one. Now in this case I cannot use item table. Typically I take an example of City ID and City; there I am able to use the geography table because they are at the lowest level. Brand is not at the lowest level, so I have to specifically call Brand ID item brand. Now you can see the rank is again correct. Both are participa. But what happens when you read rank on multiple columns which are not part of the same table? So let me bring in brand again into a new table, and let me also bring in state. I'm bringing the state column. So let me do one thing. Let me first bring in state here. I'm doing a little bit change, and then brand and net. Now what happens when I put that rank column? Let me again make it as a table visual. Again you can see the brand getting distributed. The brand ID is not present; brand is present; it's getting redistributed inside. I can sort on the state, and then I can shift and sort on the net, and you will see the rank getting adjusted. But I need a continuous rank. So anytime I create a state rank, it will get distributed into brand rank. If I create a brand rank, it will get redistributed or partition on state. I need a combined rank; they are from two different tables. So then how do I do that? So let's again create a major, and in this major which is RANK net St and brand eight and brand, I'll use RANKX ALLSELECTED. Now you know the difference between those. I can't use ALLSELECTED; the reason are all because the moment I do that I use geography State, comma item brand, and you need to be careful because I have state available in geography and customer. If I don't use the correct one uh it's going to not work. Again redistribution will happen inside that, and I'll try this out, and this this is giving an error because you can't use this different TBL. So to overcome that what I'm going to use is I'll use SUMMARIZE function. SUMMARIZE ALLSELECTED on sales table sales. So the table which I'm giving in the SUMMARIZE is sales, and as I'm giving a central table, then I can take the dimensions table geography and item into that SUMMARIZE. So here it is SUMMARIZE, and ALLSELECTED is compulsory here, and then net, and then I can use the other two parameter. This sending and dense. Now let me add this to the visualization. Now here you will see the rank is again distributed. Why? Because we have taken customer; that's what I was telling. Because I'm taking the geography State and I'm use this, then it will create a problem. So let me go ahead and change this State field from customer to geography, and now you can see the rank is continuous. Okay, in this manner you will get a continuous rank across multiple table columns. In sometime we will discuss RANK function. RANK function is also better equipped than RANKX function for handling the ties.
Now, there is a way to handle ties in rank X, but that's really challenging, so we will keep that for rank function. Let's discuss top-end function. Now, when we want to get the top end, there are a couple of options we have. One is definitely we have a top-end function, which won't give us; and the second option is basically at the visual level itself. Let me bring in brand and net into a visualization. Now, as converting to table visual, assume you want top five Brands by net. What you will do? Simply go to the brand into the visual level filter, and this happens in the visual level filter. You can go here and use top. I need top five, base is what I have net in the visual, but I can get in based on margin percentage, anything which I want, but right now I definitely want base on the net. So you drag the value here, and you use apply. Please drag a measure, and you get the top five values very easy. So whenever we need it, we can use that, but we do have a function which is known as top end, and let me explain you that function step by step. I'm going to use the new major for that, so let me click on the new major in the table tool, and the major I'm going to create is top 10 net, and the function is top n. Now, what is my n value? N value is 10, so I need n value, I need table expression, and here table expression will be all or all selected, order by expression order ascending or descending, and this kind of information is so let's start with I need top; here we already have so big, so 13 values, but I need only 10 values out of that all selected item brand, comma order by expression order on net, and what I want descending, and right now I'll keep it only this one. What happens here is basically the top-end function actually returns a table. The moment I put it here, it starts giving me error H; you get an error, calculation error, measure custom table of multiple value; it's basically table. So what I can do is I can use this as a filter in the calculate. So I'll use calculate net, first argument, and then we will have this top n end, and press enter. This seems to be some challenge, isn't it? The value top n and Branch seems like very similar to the grand total, isn't it? It doesn't seems to be filtering top end values either. Okay, let me do one thing in this visual; let me remove that's the first reason. After I remove the F filter, now again there is some challenge here. This value is not same as grand total. I can understand there a top, maybe some of the top 10 values and different now because previously the top five filter was there. This is a sum of top 10, not the top 10, and nor it is filtering it for that. What I'm going to do, I can keep values inside this one or key filters. So let me show you both of them one by one. Let me use values item brand first way; reduce it to top 10, and if I remove the net it will actually keep it top 10 only, and that's the total for that. If you don't want to use values, you have an option which is if filters can take this filter argument and basically keep the filter and apply the values automatically in this case, and this will to give me the same result. So in a scenario when you have the filter and you want to have the values impact also, you can use keep filters; keep filters can work for you. I got now top 10 net by using a major. I can use top end, and I can get whatever top I want, but what happens in case I need this as a dynamic? Is that if I choose one, give me one; if I choose two, give me two; if I choose three, give me three? How can I create Dynamic top n for that? What we have to do is we have to take help from the modeling Tab, and in modeling tab we have new parameter. Now we have two kind of new parameters; one of them is a numeric range and another one is field parameter. Now, field parameter is we're going to discuss after some time. Numeric parameter was previously also known as what if parameter. So numeric range, I'm going to create; it's going to create a new table for me using the generate series; it's going to give me the number, so I can create a series of numeric or field. I can give it a name, so name is top and number. I want it to give minimum 0, Max 20, increment by one; default is five. I keep this as checked. I want to add a slicer; I don't want it to leave for later, and the advantage of this one is basically is give me a slicer where I can enter one single select box. So let me go ahead and create that. Now what is going to do is actually it's going to create a table for me using the generate Series. Has created a table using generate series, and it gives me this parameters basically coming from them. This is the column which is coming from that. It also create by default a major for you which you can use in your calculations, and this table is a disconnected table. So whatever values we are have going to have, we need to use that in our measure, then only they going to have. You can use that various places, but what I'm going to do is without disturbing this slicer right now, I'm going to place this value inside our measure in the top and in place of this 10. Now I'll use that top and major which is already been created for me. The moment I do it, you will see I only have the five values because the default value was five. How did it get it? So there is something known as whenever you wanted to get a value which is selected, you use the functions selected value, and the selected value is going to give you the selected value. It doesn't get; you can default it. So selected value function have being used here which is returning us this value, and definitely whenever we need we can use this function. Al selected value functions give us the selected value in the slicer, but it only gives one value. If you have more than one value, then we need a different operation; usually we use values or something; we can handle in multiple ways. Basically whatever is selected is only available; whatever is not selected, if you need you need to PR fix to get that data. So now I will go ahead and change it to top, let's say one. I only got the top one value. What I can do is basically I can remove net from my visualization. I click here; I'll bring in the build a visual, and you take out net from here. Now I only got one value, three, top three, top five, top 10 in this manner. My visual will now respond to the top end values. Now understand one thing that there is one more thing which you should do. Now what happens like when we use the top end here, it's do you filter, and if you there are multiple measures, all those measure will get filtered based on the top end of one particular C. Now let's say you need top end of gross, but based on net, or top end of margin percentage still based on net. In that case, you're not going to change the second part of it, and the reason I'm telling you sometime what happens is I have the top; I have the top 10 items of this year; I want value of the prior year based on that. So there's a prior measor I have, and I need the value for that. So see my top, top n is still calculating based on that, but based on that top end I am bringing in margin percentage. Now margin percentage may or may not be the top 10 in this case. Let me rename this major margin percentage and bring this into my visualization, and I would also like to bring in margin percent, and I change the formatting percentage for margin. Top 10 margin percentage. Now I would like to sort this visual on margin percentage. This is not not the top 10 margin percentage; the top 10 based on net, whatever I'm going to use here is what going to decide my top; it is not the major which is going to decide. So in this manner I can get a major which is basically top and off some other major. So this is top-end function and dynamic top end for you. So let's look at is filtered and has one value. Understand that. Let's create a new page, and in this new page I would like to bring in brand and category, and in both the visuals we will add few new majors, and those Majors I'm going to create. I'm not adding any other major because we want to understand those two new major how to understand that measure. We also need a slicer, and that slicer I'm going to create on brand. I dragged the brand, and I clicked on slicer which is coming from build my visual. At this moment I can also take it from the insert of the Home tab, do a little bit more adjustment here. Now let's first discuss is filtered. So I'll create a new mejor using is filtered. Is filter me basically is it filtered or not? In what condition is filtered work is filtered. So is filtered item brand is item brand is filtered. You simply wanted to check this condition; is item brand filtered? We got this measure is filtered. Let me bring it here; it's giving true true true on all the rows, and it's going to give false false false on all the rows of category. So here it is giving all true. Right now there is no value coming from slicer; it is still coming from for True when the brand is in the context; is giving false when brand is not in the context. So basic basically the filter is filtered is true when the brand is in the context or the brand is in the filter; it is in the context that it is true, but look the total is false. It means it is not coming from Filter; total will be dependent on filter. So let me filter one brand. The moment I filter a brand, this is coming true; this is coming because of context, and this is because of filter. All the values are coming here; is coming true because of the filter context, but sometime what would happen is if I don't have filter, I don't want this filter; I want to take a decision whether the brand has been filtered or not. I want to display a value based on whether it is filtered or not, and that filter is not the row filtering; that filtering is the filtering which is happening on the filter. So how do I ensure that I'm only considering is filtered; is filter from the filter contexts of visual row is filter; is filter from the filter not filter context of visual Row? For that I'm going to tell you one solution. What you have to do is you have to create a new measure, and we going to call it it's filtered one, and you can use calculate all selected; don't use all about selected values, and let's bring in this mejor. Is filtered one. Now you can see is filtered is false for row, and it is not obing the context. Let's bring in another visual; expected is false. Now let's filter any value; it is filtering, and now it is giving true, and that is expected. If even if I select multiple values, it's going to be true. So is filtered is able to tell us yes, it is only coming true when something is getting filtered. So the second function which we wanted to discuss is has one value. Right now what happened if you remember when I clicked more than one, I'm getting through still, but I don't want; I only want let's say currency; we only want to select one currency. If one currency is selected or one country is selected, then I will show the data in that particular currency. So if let's say we are showing data of USA India together, I have to show in one of the currency Global Currency. So one of the currency I'll call Global Currency, and when both India and USA are selected, I'll show it in the Global Currency, but when India is selected, I'll want to show the local currency which is rupee. When only USA is selected, I want to show in USD. Let's say Global Currency we have decided Euro. So when both are selected, we are going to show them in Euro. So in that case I also wanted to know that one value is selected. So I want to know has one value. So let me create a new major and check has one value. So has one value first of all has one value item brand; does item brand has one value? First of all we wanted to check, so it's running true. So it means context is playing a role, and the filter is also playing a role. So the filter context because of that is coming false here; it's true here. Now let me filter a brand, and because of the interaction it's going to filter; all the values are still true; the grand total is false, and most of these categories have more than one brand. Let me select one brand here; everything here is true because one brand is selected. Let me select one more brand. Now look at the data here; this is still coming true because the row only has one brand; this is false now here; category one has two brand, so it's coming fine; both brand belongs to this; this is coming coming true because only one of the brand appears; this is coming false because more than one brand are applicable here; this is coming true because only one brand is applicable here. What's happening depending on this number of values availability; this is also behaving; so one value or more than one value. So now we will bring in the measure just like we have done in the case of is filtered using the has one value all selected. So okay fine, we'll take a decision based on has one value one, and we'll use calculate, comma all selected; we'll say we only want the filter to be honored; we don't want R to be honored, and let's bring in this new measure also. Now what's happening here because two values are selected; it's giving false everywhere. So now as one value is behaving based on the total selection; so total is one then it is true; nothing false, and more than one also false everywhere it is false. So in this manner you will be able to take decisions based on is filtered and has one value. What to use, what not to use, but remember one thing that use has one value and is filtered only if it is most necessary. I've seen sometime people unnecessary check is filtered and has one value. We don't have to add a condition when it is not needed; it is going to unnecessary add a calculation to it. So like in the row we know the things are in context; we don't need to check is has one value. I know the row is going to have a value, so you don't need to check; we only need to check when we want to change our calculation in case of grand total. Let's say the grand total we can use is filter; sometime we can also use is in scope which we learn sometime later. So is filtered has on value find out is it selected; is it in the context? In Power BI you will find us always talking about a date table and a calendar table. Why date table or a calendar table? A table with A continuous dates is so important; it is because all the Power BI time intelligence functions require continuous dates. These functions include date add, dates MTD, dates qtd, total MTD, total YTD, and many other functions which require continuous States, and a calendar table or a day table can ensure continuous States. We have also need to make sure that we mark them as a date table; that will ensure that we have continuous dates. To generate a calendar, we are primarily going to use calendar Auto or calendar function. As we move forward, we will discuss the differences between the two. To start creating the calendar, let's first start with calendar Auto. Calendar Auto is a very versatile function; it can automatically generate a calendar based on the dates available in your Power BI schema. It also provides you a parameter using which you can set your financial calendar. So let's understand calendar Auto in more details, and to do that I'm going to use the table View, and I'll click on the table View and go inside the table View, and here what I'm going to do is I'll click on any of the tabl so that I have the table tool visible to me, and inside the table tool I have option for new table. Calendar Auto is a DEX function which can give us a table. Now what I'm going to do is I'm going to click on the new table. I'm going to give this name to this table is date Auto, and I'll use calendar Auto. For calendar Auto will take this one argument; this calendar is going to return us. So calendar Auto is going to return as a table; table of continuous States. So it was automatically taken the start date; automatically taken the end date based on the your financial year or your calendar year, and it's going to return the continuous dates, and continuous dates are really important for for doing time intelligence because most of the time intelligence functions in Power BI requires continuous States, and we will learn when we add the columns also like some of the function like start of year, end of year which we will be used to create start date and end date would also require continuous date. Calendar aut of function you only needs one argument which is basically the physical month and date. In my case I don't want to give because I want to create a standard calendar month, so it's going to do that, so and what also calendar Auto does it based on all the dates available in the model is going to find out the minimum date and take the start of the year. Now if you want Financial year, let's say Financial year end is third month, then it will start the calendar from April; it is 12 month, it will start January from January. So based on that minimum date less than or equal to that date is going to find out the year start date; similarly go to the max date and maximum across all the dates and goe find out using that date we'll find out either a date which is greater than or equal to that particular end date is the year end date. Now if it's is a physical year, let's say you shoot March, then 31st March is going to find out, and first aprile is the start date based on which is going to be calculated. Now here we don't want to, so we can simply say calendar. So calendar Auto will give you all the dates, and you can create a calendar using calendar AO. Now this is the first way. Let me sort ascending and show you what date I'm getting here. This is the first date as you know my data is it from the October 2018, and I'm getting a calendar which is from 1st January 2018. My data lasts till 2020. So if I do sort descending, you will see that it is going till 31st December 2020. Let me do one thing because my data is starting in October let's say and ending in October again. Let's say if I want to start my calendar with October Financial year, what what is my financial year and month which is nine. So what happens when I start with nine? You press enter; definitely because my data has started after the October 2018, it's still starting from 10th 2018, but interestingly where does it is ending; it's ending in 2021 because remember I do have data in October 2020. So when I have data in October 2020, so that complete Financial year has to be taken, so and that's why it has claimed till the end of this. Now post that if you want to create additional column, you can create here or you can use a function which is known as add columns. Now we will create a date table or a calendar table using the calendar function. Now for that I will go to table View. Uh, previously we created using calendar Auto. Unlike calendar Auto where you only need um the month and and it automatically identify date, the calendar function cannot do it; you have to supply the dates. Let me click on any of the table, and I'll get a table tool, and inside the table tool let me click on the new table. I click on the new table; I'll give this table name as a date table, and then I can write down the function which is calendar. Now the calendar function
requires two arguments: the first argument is a date, and the second argument is also a date—start date to end date. Now, it means we can start with any date; we can end with any date. It will not force us to go to the start of the year; it will not force us to go to the end of the year. But usually, when we start, when we create, we'll take care of these things. Now, sometimes what happens is we can find out, with the set of dates—let's say there are few dates only which are available—then with that set of dates, we can also start. So I'll give you an example of that.
So, the calendar function takes these two arguments, but what does the calendar function give? So, the calendar function returns a table, and that table is a sequence of dates, and these dates are continuous dates. Remember that we require continuous dates for most of the time intelligence functions, and that is why having a date and calendar table is also really important, which provides us all the possible dates between the set of dates, or the continuous set of dates, which is comprising of all the dates from the minimum date and the maximum date which is needed for our data. It is really necessary to have, include all the dates and have the continuous dates. Now, in the calendar table, we don't include the time. So, in case you require time also, sometimes we create a separate timetable.
The calendar function, taking two arguments and returning a table of continuous dates, which we would be needing to create our date table, having the continuous dates. So let's start with the first date. Now, to give a date, I can use a date function. Now, the date function requires three arguments: first is year, second is month, and third is day—three arguments which are required. So I want to start from 2018. My data is starting from October, but I'll start from 01—first month, 01. Then this is my start date. Again, I need another date for the end date. So, the end date, I can give again—year, month. So my data is still 2020 October, so I'll use 2020, 12, and 1. I did not add one parenthesis at the end, but DAX does take care; if you are missing one at the end, it does end. I can click on the submit or press Enter. Now you can see I got a calendar. I can use sort ascending to see what all dates I have and sort descending to see what end date I have—start date and end date, we are able to know. Now, this is the first very simple way when you can create.
Sometimes what happens, you say, "No, no, I want to add an end date where you want to end it." Let's say I want to add it today; my calendar should go till today. So we can use the function TODAY. So every time we refresh, the TODAY will change, and it can end on today's date. When I'm recording this, it is 1st January 2024, so it will end on 1st January 2024. It can end on any other date. Sometimes you might want to end it on the last date; you can use this one, or last month's end date. Let's say this is something different; then I want to add last month's end date. For that, to get the end date of a month, we have a very good function which is known as EOMONTH. The EOMONTH function doesn't require continuous dates. Remember, uh, other functions—there is an end-of-month function which requires continuous dates, but the EOMONTH function doesn't require it; it just requires which month and date you need. So today is today's date, and I need today's month end, then I can use zero. Let me show you that. So this is the current month ended, but minus one gives me last month ended; plus one gives me next month's ended. So I can use these kinds of stuff. I may also like that, you know, like to start from the start month of the minimum date and assume, right now, for simplicity, I have only two dates, which is the sales date in the sales table. So I have one sales date where I can find out the minimum sales date. I have a delivery date; maybe, ideally speaking, the delivery date cannot be less than the sales date, but assume it could be. Then how do I take the minimum of two? So for that, what you can do is MIN of MIN sales date and comma minimum delivery date. Okay, so double minimum—MIN of MIN of delivery and for both we can take minimum. So the MIN function—this is another behavior of the MIN function where it can take two arguments. So the typical behavior was the MIN function will take only one argument, one column, but here it can take MIN of MIN. Okay, this will start from the minimum date, probably from the middle of some month. Let's go ahead and check it out from here.
Now, what I can do—this is too heavy a formula—so let me go outside this one and see if I can create a variable. Go here; I'll create a variable—VAR minimum. So this will give me the minimum date, which is 13th October, and I can create another variable, or I can come here and write down EOMONTH. Now you will say, for the start of the month, why you're using EOMONTH? I'll tell you—EO; there's no function like SOMONTH or STMONTH. EOMONTH is a function which I have with me. So if I give minimum and minus one, it means it is going to give me last month's end date, but the beautiful thing with the DAX date is if you do plus one, simply you do the plus one, it adds the days. So plus any number is the number of days you want to add. So I got last month's 10th, and I do plus one, which is going to start from the current month. You will see it start from the 1st October 2018 in this manner. So these are the various combinations basically which you can use to get this. Now I'll tell you one very quick combination. Now this is going to give you the start of the year: minus one STMONTH of the date. So you subtract the month in the negative number, so multiply your month for the date by minus one and do plus one; you will always restart of the calendar. Basically, what happens in the 10th month, if you do minus 10, so MIN - 1 is 9, and MIN - 10 would be last year December, and then you add plus one, means you this year January, in this manner. Depending on the requirements, we can create different, different dates.
Okay, now we need to go ahead and add new columns to this calendar or date table, and then we also need to join it with our T table. So what I'm going to do first is we are going to add the calendar months, date, and then we are going to add some financial months. First, we are going to add calendar months, like start of year, end of year, start of month, end of month, start of quarter, end of quarter, all those, and then we will go and do the same thing for financial. Financial—we limit ourselves to financial year and financial quarter, etc. We would like to enhance our calendar table or the date table, and the first set of columns which we want to add is basically the month name, the quarter number, the year—these are the columns which we want. Now, to start with that, I would like to add the columns. So one of the ways to add a column is that what we have learned so far is click on the table or the column, and then you use this new column from the column tools of the table tools, but that's not extendable because DAX scripts are not the script which you can, you know, find out and take. If you create columns, if I need to take this table to another file, I actually need to create those columns again. Or, to overcome this, we can use something known as the ADDCOLUMNS function. Now, first of all, all we need to understand what this ADDCOLUMNS function is. The ADDCOLUMNS function allows you to add the column to the existing table, which takes the first argument as a table. Then you can give the name, and the expression—the expression is the expression which you want to generate your column; it could be a calculation, it could be a static value, whatever you want. It could be a table, and the name, and the expression. Another thing which you should remember: this expression, if it is using some column, it is limited by the table which you have provided. In this case, in the ADDCOLUMNS, I'm going to provide the calendar, and calendar is returning me only one column—date—it means all my calculations would be dependent on date. Any column which I'm adding—new column which I'm adding to this table—let's say I say column, let's say month year, I added a month year column; that column cannot participate in the next column calculation—only the table's column. It means I created column one, and now in the column two, column one can participate; that cannot happen when we are writing down the ADDCOLUMNS script. So let's begin this journey. ADDCOLUMNS—the first argument of ADDCOLUMNS is a table, and then we are giving a table, and then we're going to add new columns, and this is also finally going to return as a table. ADDCOLUMNS returns as an enhanced table which will contain more columns. So, and to get additional rows, I'll press Shift+Enter or Alt+Enter. Now I may have to make it a little bit smaller here so that I can show you more columns, or we will use scrolling—one pixel smaller.
Now, the first column which I would like to add here is year—which year I belong to. Very simple; I have a YEAR function which can give me the year of the date, and basically because I'm talking about calendar here, so it's easy for me—only column which I have here is date. I cannot give a table name here; I need to use date. So I got my year. Then I want a next column, so then I need to give a comma at the end of this, or what we can do is here is sometimes this is a little bit better. Let me remove this column comma also; we give the comma at the start of the line—easy to comment such lines. Month number—how do I get the month number? So we have a function MONTH which will give us—we take only one argument—date. So I got year, I got month. Quarter—I need quarter number, basically this. You, instead of month, you can call it as a month number; maybe we want to use month as MON, and quarter number. So how do I get the quarter number? We have function QUARTER, and we'll give a date—only one argument; it requires only one argument—date; it gives us the quarter number. And before we go forward, let's close this ADDCOLUMNS by giving a parenthesis at the end. Table name, expression, name, expression, name, expression—finally close parenthesis. This is going to give us a new table with the enhanced number. We got year number, month number, quarter number. Here we simply calling it C; I need, let's say, month name and month. Here we create that, so I press my cursor Shift+Enter, Shift+Enter, Shift+Enter. Now, only challenge with this is that this will keep on moving down, so we will have lesser things to see, but we'll do so. First column—double quotes, I want to give the name—name is month, and here I want it in the one like Jan, Feb, March. For that, first time I'm using a function which is known as FORMAT. The FORMAT function can take three arguments: value—the value could be a number, value could be a date; format, which we can give in double quotes; the format—there are rules for giving this format—what means what, in case of number, in case of date—that you can find out on the documentation; local name—sometimes we use like, is it US, or is it Great Britain English or something like that—that can also decide what format you want, especially useful in case of date. Now we go to FORMAT, and the first argument is the value, and here my first argument is date. Now you can go ahead and now this gives the format, and the format which I want to give is MMM. MMM means month name, like Jan, Feb, March, and MMMM means complete January, February, March. Close, press Enter, and you get here January, February, March, you can see below. Now if I give MMMM, we will give January, February, March. Now this is a text column, and in Power BI we have a problem—the text column cannot sort by its name—by—I can simply call it some month column will sort automatically. We will discuss the solution for that problem a little bit later, but before I solve that problem, I want to come to the next one. Double quotes, I'll give double quotes, and here I'll give month here. Now, month year—I want the column month year. What is the calculation? I again want to use the FORMAT function, and date; I would like to give here the format as MM-YYYY. 4Y—month—Jan, Feb, March, April, May—three digit, and 4Y means year—four year—and I press Enter. Because my last parenthesis already there. Now it gives me January, February, March. I got my month, month year also. Now this is my calendar, and the next column which I need basically is the quarter—QTR quarter. We already have a quarter number, so I'm simply calling it as quarter, and this time what I'm going to do is the format which I need. So here what I'm going to do—FORMAT function, and the first argument is date; in the second argument, I would actually like my names to be YYYY. I want Q to be written, but if I give Q, it will give me the quarter number. I'll tell you—if I simply give Q here, it gives me the quarter number. So how do I get a Q? So I can use backslash Q—means ignore. If I want a hyphen in between, let me use hyphen and see—HYPH is not a letter which FORMAT is going to identify, so it's leave as it is. To identify Q, so I use backslash Q to ignore the Q and treat it as a normal letter q, and next second Q I leave it as is. So for every Q, let's say you want to write quarter, then let's say T and R doesn't have a meaning, then you can give, and if the T and R has a meaning, then you have to give with every letter like this, but Q and R doesn't have meaning, so I can leave it as is. Now, the format—why have I knowingly taken this format? This format is a sortable format. The previous MON format is not sortable. What do you mean by sortable format? If I give YYYY and then give the quarter number, every time I put it, it automatically gets sorted, even if it is a text.
Now let's go to the visual level and understand that. So let me add a new page, and in this page let me now create a table using month here. Simply drag month here, and it will create a table. Let me drag quarter here, and as you can see the quarter here which is only called quarter, it seems like an unsorted position—Q1, Q2, Q, Q4, Q1, Q2—but month year is not. How do I sort month year? MON is not in a sortable format. In Power BI, we don't have a way to tell the system that this is month year and sort it like date. No, we need something known as sort column. So I'm going to create a new column here which I'll call as month year sort. How can we get sort? One way is I create YYYYMM using the format which is a sortable format, so YYYY, 4Y, and MM is always a sortable format for month year, or I'll tell you one more way which I want it numerical. So I say year—I'll use—I'll use function YEAR, YEAR date, multiply it by 100 plus MONTH of date. What does that will do? If this itself is a sortable, whenever you put it, will got sorted, but how will this month year sort? Will sort month year. So for that, what you have to do is—make it a little bit smaller—click on the month year column, either here in the table view or here in the data view, click on that column; you will get the column tools, and the column tools should show your column which you want to sort. Go to sort by column in the middle, click down, and choose the column on which you want to sort. This column you are going to choose—the column you are going to choose is going to sort your column now. So month year sort follows the sorting of month year sort. So month year sort is a column which can sort my column correctly. It is done. Now if I go back to the visualization, you will see that the columns are sorted correctly.
Now we would also like to have one more column which is year week and week of the year, and then again we'll add year week, or we can only call it week number, but I would like here to be year week. For that, what I'm going to use is the YEAR function on the date again, multiplied by 100 plus—there is a function WEEKNUMBER—date requires a second argument also. In the WEEKNUMBER, the second argument can be one, means starting from Sunday; it can be two, means starting from Monday. Again, we have arguments from 11 to 17—from Monday, Tuesday, Wednesday, and so on—17 means starting from Sunday, and 21 is for ISO. These are some of the arguments which you can give. The similar kind of arguments are also available for WEEKDAY, and some of them might not be in documented format—means you will not be able to see that these arguments are available, but you will be able to use—and when we will do week start date and week end date, we will let you know. Right now, I'll keep it two, so that I'll have a Monday week start. Let me add weekdays here. How do I add weekday here, and then we will discuss whether our week number is correct or not. So how do we add weekday? There's a function known as WEEKDAY, but it's going to give me numeric here. I don't need 1, 2, 3, 4, 5; I actually need the names. Again, WEEKDAY has an argument like 1 and 2, so I'll use FORMAT on the date, and if you give date three times, it is MON—Monday, Tuesday—in the short form; four, it is going to give complete. So I'm going to use 3 days. Now, DDD in the FORMAT function to get the weekday name, and the reason why I—that let me let you know that the first week—this calendar itself starts on a Monday. So starting on a Monday, and if the first week goes till Sunday, it means this is Monday-Sunday week, and this is week number one. Then we have week number two, again from Monday to Sunday. So the week number is using Monday to Sunday week, and weekday is verifying that. Well, the very first level of our calendar is ready. Let us start adding the new columns like start of month, end of month, start of quarter, end of quarter, start of year, end of year. Now all these will depend on whether your year is a financial year or calendar year. First, we'll add for calendar year, and then we'll try to create our own logic for the financial year. We have a few functions which can do this for us, but they have a limitation. How to understand that limitation? What I'm going to do is I'm going to change this calendar statement a little bit. So let me comment this particular line and put it again. Now in, I will not use EOMONTH here, and I'll tell you why I'm doing so. I'll use minimum, and then I'll it till today. So let me commit this change, and you will see my calendar is now starting on October 13th. Let me check where it is ending; it should end on—ending on 1st January 2024. Now let's try to use the start-of-the-month function. Now the start-of-the-month function will not work in the ADDCOLUMNS. Start of month—basically I need a date on which this month has started, and I'll give date; it is not taking it. So parameters is not correct type. So it basically needs table name, column name. We say, okay, fine, it's not working here; that let me go ahead and directly add it. As of now, the quickest way is to directly go and write down a new column, and the new column will be month start—START OF MONTH function. So we—as you can see, we have START OF MONTH, START OF QUARTER, START OF YEAR—START OF MONTH—I'm using it—require
Only one column. The Continuous dates and I'll give the eight date table. And let me press enter now. Ignore the first one. If I go to the November month, it is showing me the correct start date. If I go down any date after the October month, it is showing me correct dates. If I go here also, you will see that it is showing me the correct start dates of every month except the first month. Why is it that behavior? So the reason behind this one is that card of month require continuous stes and it cannot go beyond the boundaries of the date which is contained in the column which has been supplied.
So what happens if the month start date is not available? It will take the minimum date available in that table. So because of that, the start of the month is happening at the 13th of October. Same way when I take start of quarter now, start of quarter again has the same problem for the first quarter. Instead of from first October which is the quarter start, it will start from October 13 again because it doesn't find the 1 October; minimum date whatever it finds before that, it's taking that. If I use start of year, you will see the same issue again; no 1 January, it's October 13th which is the minimum date available. Continuous state from month start to month end. And let me use the function end of end of month. What happens now? Very happy; first month is coming correct, but let's go to the last value. January doesn't end on first, isn't it? It doesn't end on first; it ends on 31st January. Not able to find because there's no date which is available after that, so it's going to end there. Okay, what happens to the end of quarter? You will see the same issue with the end of quarter, the last date. What I can do is s descending; it will come on the top. As you can see, the month is ending on the last year. Same way for the year, if you try again, the year will also end on the 1st January, so it cannot go beyond the date; it has to stop there.
And because of this reason, we are unable to use start of month, end of month if we are not using a standard calendar. Specifically, if the calendars are not starting and ending on the standard month start date and month end date, then we cannot use it. If your calendar is starting on standard month start date and ending on standard month ended, you can use these functions without any doubt, but I need to tell you the Alternatives. What I'm going to do is I'm going to delete these things and I'll tell you how to create it without using these functions. Now you learned these functions. Only one argument; these function required other than the end of year and end of quarter. End of year and end of quarter, start of year, year function and end of year function can take another argument which is basically year anded which can also be supplied to get the financial. Again, the limitation is if you want to create the financial year, the calendar should start from the financial month start date and should end on the Financial month end date, otherwise the end dates would not be correct.
So what is the alternate? So I'll tell you here. So let me create start of month and new column in the add column. I'll continue to add the column in this add column and the what is the date I want? I want start of the month and we'll use function e month. Now e month gives end of month and for the row in the date, if I give zero, it will give current abundant date. So what we do is we go to last month end date, which is minus one means last month end date plus one. So two argument it takes; EO month, first argument is date, second argument is which month and date. So minus one means last month and date and then I'm doing plus one in Dex. You can simply add numbers to a date to travel number of days you want. Then we press enter and now we got the start of the month and as you can see this is correct, but let's go start ascending and you can see though the calendar has not started on the first date, there still getting the correct start of the month. Now end of the month is simple; we know that this there is a function which actually actually is for there for end of the month. Let me write down that one; end of month, EO month, which months and date I need? I need the current month end dat; it is very simple for us, just give a zero, enter, and we got the end dat. Now we have to check it for the largest statee we have; S this ending and if, as you can see here, it gives us the correct month and date though the month and date is not present in the calendar or the date table or the dates which are available in the table which is we are using here. The date column itself doesn't contain the dates which we require.
Before I'll go to the quarter because quarter require a little bit of logic, I'll show you how easily we can achieve the start of year and end of year. Now start of year, I'm showing you the calendar later on we'll come and develop the logic. Shift enter, shift enter, start of year. How do we start the year? Now we will use the same function, this one only. Now understand when I subtracted one month from October, when where did you went? September. If I subtract two then August. What happens? So if I subtract one, you are 1 month less. So if I subtract nine, where would you reach? You would reach January. But if I subtract 10, where would you reach? You will reach December. So if I subtract 10 then you will reach end of the month December and then plus month will give you January. So how do I know the month of the date? So I can use month function and there I can give date as an argument. So what I'm saying here is basically from the date you have to go minus one star number of months which you had, so you will reach 10 months behind in this case for October. Minus one is September, minus 2 is August, and same way you will reach -10 means last December and plus one means you will reach the start of the year. And as you can see we are getting the correct start of the Year date here and let's sort ascending and check it out; we are also getting it. So start date is correct. Now end date, how do I reach end it? Now how do I identify how many months I need to add because months are changing? January is different, February is no. To reach 12, we need to reach 12 month, isn't it? What would happen when we give zero October? When we give two what will be happen? November. When we'll give two it would be December. December is 12, what is the current month? 10. 12 - 10 is 2; we need to reach 2 months. If we are in September, if you give zero September, 1 October, 2 November, 3 December, 12 - 9 is 3. It means if we subtract the month from the 12, we will exactly get how many number of month we should go ahead. So what we are going to do here is we copy paste this one; we don't need to add the plus one now. Simply go ahead and say end of year, EO month, 12 minus the number of months which is is already passed me that include the current one and we should get end of year date. So start of year we got using the month number, end of year we are also getting using the month number. Enter and let's look at the date. Perfect end of year date 2018. Thought descending, check what we are getting for the 1 of January 2024, 31st of December 2024; we are able to get it.
Now we comes to the logic of quarter. Quarter is not very simple because what happens is we have these quarter which are ending every 3 months. We are right now preparing for the calendar; it's easy for us because they are we can use division by three as a criteria. Actually, even if the month start from a common date and the quarters, then there are couple of ways. One way is for January what we can do; month is one, so I subtract -1 month from E month, I'll read December and then I can add plus one to get the 1 January. Similarly for February, u monthus 2, 31st December Plus 1 day we'll reach January. For March, minus 3 and plus one day we will reach 1 January. But for April, the formula little bit need to change because now I need to only say Min - one then -2 then minus 3; they say okay fine. What we can do is we can find out their remainder by dividing by three, but the challenge with the remainder is when we take it from January it is fine; one means one, remainder is one. For February, remainder is two; for March, remainder is not three, the remainder is zero. So we say fine, we can adjust it, so we use start of qtr and you might have to actually think about this logic little bit. I have done quite a few video and few people uh do get this mathem ma matical equation how I'm changing it, so just pay attention; you might have to rebuild your own Logic on that. First is very simple; if mod, mod is a function which gives me remainder, so it takes a number Division and gives the remainder. So we are learning a mathematical function mod here. Mod functions give us the remainder. What is the number we need for which we we need the month number? So month of date and I could have used this inside a variable, so let me do one thing where underscore r equals and I'll tell you when you inside the add function when you use variable how to use that. Now if the mod of the month from 3 equals to 0er then three; if it is becoming zero it means if it is third month the mod is coming zero it means it is three otherwise it should be same as mod or it could be same as the it should be same as mod because for four you can't say no no it is a month number no. In case of four I need one and if you want to avoid this calculation twice you could have created a variable on this first and then used it. So now I got my calculation; this is this is what is going to give me 1 2 and 0, 1 2 and 0, 1 2 and 0. And then what it will convert it the if statement will convert it into 1 2 3 1 2 3. Shift enter, tab tab just and I'm pressing tab so that you know you're able to understand the code; the code is aligned better. Now I'll so when you use variable you need to write down written statement and in this case also you can do this but and I'm going to write down in the same line. So now it is very simple for us; EO month of the date Min -1 star this remainder what we got underscore remainder and then add the + one, add the plus one to date. Now let's look; are we getting the correct one? This is start of quarter for descending. Let's s it ascending; let's sort it ascending. October, after that we got January and this is what we are getting on the 1 January; seems correct. Let's look at April and then we can go and simply check the start dates; this is quarter number so don't go by this; look at here 1 January, so this is 1 April, that's fine and we can look at all the quarter start dates; all quarter start date seems correct. Quarter end dat now if I so what happens for January? I need to go 2 months ahead; February I need to go 1 month ahead and March I don't need to go. So there are so what we will in this Cas is we will say let's write down the formula for this one; I erased it; EO month date 3 minus the remainder and we will reach the end of month so we don't need anything for that. Let's Commit This and let me go down; you can see this is ending on 31st December, end of quarter. Let's scroll a little bit down and then this one; you can see a change of date here on this line in the January. Let's look at all the quarter end dates; seems correct and not dependent on the dates which which are available on the calendar. So now we are able to get the month start date, year start date, quarter start date, month end date, year end date, quarter end.
Next most important thing is Week start date, week end date. So now we would like to add the column start of week and end of week. I'm going to do is while we can add in this table, but this table has too many columns. One of the ways that I remove some of the columns or I add at the start, but what I'm going to do is I'm going to add those column in date Auto where we only have couple of columns and and now because it's a script we can come back and add the columns into the date table; we're going to do at the end. So start of week, end of week; no standard function; we have to create it now. The logic, the way we have to drive it; let's say Monday is your start of week. So Monday means you to go zero behind; Tuesday means you to go one day behind; Wednesday means you to go 2 days behind; Thursday means 3 days behind Min subtract simple number subtraction will there is a function weekday function also which can give us for Monday 1, Tuesday 2. So every week which you want to start, first of all you need to have a week day for that kind kind of start. So if I want a Monday start or if I want a Sunday start, what I'm going to do is there is are arguments which can help you and these are other than one and two and let's try those out today. So to start with, let me first of all start by add column and I would like to add here a weekday okay so and not weekday number I would like to add a weekday name here; weekday name. How do we add weekday name? We have learned just few minutes before is that we can use for format function for that; format date again calendar Auto also gives us a date; let's use DD d d four times give us the complete one. Alt Enter, Alt Enter. So we got Monday, Tuesday and S ascending is the date, so this start so any Monday week cover the first week as a full one. Now let's play around with one argument here where I want to have a new column which is nothing but week day as a number and week day is a number; week day date, first argument column return return type 1 2 3; try 11 though it's showing an error, but as you can see here it is giving 1 2 3 4 5 6 7 1 2 3 4 5 6 7. So Monday is day one. Let's try the argument 12. So in case of 12, Tuesday is 1 and then mon other than that we have 1 and 2 also as an argument; one means Sunday and two means Monday and one means Sunday start. So I'll tell you the formula and you can use those argument as you require. So let's say I need I actually need the Monday, so I can use 2 or 11. So date it's a very simple formula; date minus weekday we'll reach a day before; not reach Monday, we'll reach Sunday because on Monday I'll subtract one day I'll reach Sunday; in Tuesday I'll subtract two days I'll reach a Sunday. So we'll say okay after that just add plus one. So this is nothing but Week start dat; what we got here is Monday as Week start date, then again the next Monday is again the week start date and you can check what is the date on the Monday. Now if you need Tuesday is the week start dat what you need to do; no change in the formula only Chang in this parameter just do that; commit come out. Week start date becomes the Tuesday start date. Same way you can work for Wednesday; this is Tuesday, this is next Tuesday, this is the entire week, so get it; we'll keep it Monday; you can keep it 2 or 11. What is week and date? Week and date is six day ahead of the Week start date; I want to add six more so I can simply go ahead and add plus seven here and sometime what we is 7 + 7 minus week day; both are going to give you same result. So either you do plus 7 here or you do plus 7 here; both in same and we cannot have to column name with the week start date; you need to week end date. Press enter and you get the end date. Now the start date and that's your end date; you're ending on 7th which is a Sunday then you ending another on Sunday; this is this. So now any calculation you know 11 12 13 14 15 16 17 are what we are looking at. So now you understood the calculation; I can copy this and this is why I prefer this manner; I can go to the date table just shift enter or Alt Enter, backspace backspace backspace in this case and then I simply press enter here at the end and I have Week start date and week dat end date also available here and as this is not starting from 1 January so that's why you have the weeks which are starting from The Middle of the month as this is starting from 13th of October based on that our weeks are coming here.
Now I want to create Financial year start and financial year end. Now because my months are standard months so the calculation for the month start date and month end date is not going to change but the year month calculation will change because let's say if my year starts on April, the April is the first month and let's consider that case only when April is the first month. So again my date table has a lot of columns as we have done in the p we are going to create these here and then we'll take them to the other scpt now. Let we start with the start of start of FY; let's call it Financial year started, start of fi where do here start? The year starts in 1 of April; years end on 31st March. Any month like January, February, March they have their year started in the last year; month which are after April which is 4 to 12 the month the year started in the same year. So this is the logic which we are going to use and for that we are going to use an statement. So what I'm going to do is I'm going to create a date tape date using the date function but and remember four and one are constant right now. The only thing we are doing is keeping a little bit of hard coding; we say month number is four and day is one that is constant here is something which we need to change if the month of the date is in the row now is less than four then the year of the date is not starting this year; it's starting in the last year. So whatever year you have it's minus one otherwise you can continue with the year you had because your ear is going to start in this year only. What we are saying is the in the year part of this one is basically that if the month of the date is less than four the true condition then year is in the last year the Year start and if it is greater than or equal to then year is starting this year and after that we can simply hardcode 4A 1. What we got; first uppl as our start date. Now this is starting in October so it will have that. Now we have to travel till 31st March and 1st April to see is there a change happening. So these are the two rows we are looking forward and look at the years; so the years are changing in the month of April. Now end date again we will keep very simple Logic for the end date but here what is happening; if it is before April it's ending in the same year; after April it isend ending next year; the Year doesn't end on this year. Shift enter, past this end of FY and if it is less than then it's ending this year; if it is more then it's going to end next year plus one; either it ends this year or it ends next year; where does it end? It doesn't end on April; it ends on 331st; we have to do the adjustment and then enter or commit.
We got the date of 31st March as the end of year. And if you can scroll down again to the same place, March, look at these rows: March, April. End of year is changing, so we got our financial year. Now to get the month number and the quarter number, the formulas which I wanted to use need start of the year, start of FY. Now the challenge with us here is basically that this table, which the current table of the add columns, doesn't have that. Because they are calculated in this table itself, we cannot use them. So now what to do? What I'm going to do is I'm going to put this entire table into a variable that we call that where_tab equals. And then what I'm going to do is I'm going to go down; it's a variable, so I need to return something. I'll return this table: return_tab. Let's do a little bit of alignment change, you better understand that. Enter. Nothing is changed; this is the same table.
Now what happens is this new tab, which is coming down, which is in the return, has all the columns what we need. And now we can use start of FY and end of FY; the reference point now it is available in that table. So if I now add add column on this tab here at this place, if I add add column, it will have these two columns, start of FY and end of FY. And using that we are going to drive out our now our month number, financial month number, and quarter start date and quarter end date.
One of the most important things in any data analytics or business intelligence analytics project is time intelligence. Time intelligence is critical to compare data against time. You want to compare this month versus last month, this month till date versus last month till date, this month versus last year, same month this year versus last year, quarter versus quarter, Q-Q, year-on-year, week-on-week. These are the kind of comparisons you wanted. These comparisons are really important to understand: are we doing good or bad? Power BI provides you a huge list of time intelligence functions, and sometime you have more than one option to achieve one thing. Now there are ways and means you can write down your own time intelligence function using the other functions, or you can get the value, let's say MTD, using the standard MTD functions. And then you can also get that using, let's say, date between or maybe using the filter function. Now for everything there is a fit for purpose; it is really important to understand all these time intelligence functions in Power BI to make sure the time intelligence works for us.
The first step is to make sure the six steps which I'm going to tell you, you ensure that these six steps are done in your Power BI setup or your schema is following those six steps or six rules. Suppose that we are going to check in our own file that yes, we are right now following these six steps while we are going to do this time intelligence journey in Power BI. There are six rules one must follow to make sure the time intelligence work in Power BI. If you don't follow these rules, the time intelligence may fail or may not give the desired results. So these six points or rules are: use date table; you have to always create a date table and use it, and you have to join the date of your fact with the date of the date table. The date table is marked as a date table. Now once you mark date table as a date table or calendar table as a date table, it is going to ensure that you have continuous dates. Continuous dates is really important for all Power BI time intelligence functions. Use columns from the date table. When we will use the visualization in Power BI, you must remember that you have to use the columns from the date table, like date, month, year, etc., into visualization, into slicer, into filter, and into measure; all these places the column should come from the date table to make sure the time intelligence work properly. The date does not have a time stamp. Now your fact table date might have a time stamp, and sometime because you have just taken the data type as date, you might not be able to see it. So the best practice is to change the data type as date time and then choose a format where you can see the time, and then see you don't have any time other than 00 hours or 12:00 a.m. You must not have any time other than 00 hours or 12 a.m. If that's how your date is looking, then you can use that. If there is any other time other than 00 hours or 12:00 a.m., like 2 a.m., 2 p.m., 1:00 a.m., 1 p.m., etc., then you should create a date column; that you can do in Power Query. You can change the data type as date, and if you change it in Power Query it will lose the time stamp. And if you want to do it in DAX, you can create a new column using DATEVALUE. Once you have ensured that your date doesn't have a time stamp, you can join it with the date of the date table. And because we are going to create date table using CALENDARAUTO and CALENDARAUTO function, that is going to ensure that your date table will not have a time stamp in the date column. You have also need to make sure that your date table has all the dates, because if your date table doesn't have all the dates, your time intelligence may not work correctly. If you are using a date from the date table and you are putting any measure from the fact and it is started showing blank in the date column, then it means you don't have all the dates. When you're using CALENDARAUTO function, it can make sure that you have full coverage of date coming from various other tables, but when you're using CALENDAR function, you have to make sure that you do the full coverage. This is another important point you should remember: avoid bidirectional join. If you have a bidirectional join, your fact table will filter the date table. What does it essentially means is if there is a date missing in the fact table because it is missing in the fact table or because you have applied some filter and now the dates are less, it may actually reduce the date in the date table which you are using in a time intelligence function. And once there are not and once the and once continuous dates are not available, your time intelligence may error out or may not work properly. If you take care, so these are the six rules, and if you take care of these six rules, your time intelligence should work properly.
We want to start time intelligence now. Let's make sure all the six rules has been followed or not. Let's start that with the model view. Do we have a date table? Yes, we have a date table. Is date table marked as a date table to ensure that we have continuous dates? Right-click, Mark as date table. Select a date column. The date column should should be the one which is a primary key or which is the main date column. It may be coming from your sources; it's not necessary you need to create it in Power BI. You can create it at the source, you can create it in Power Query, you can create it in DAX. Make sure the dates are continuous, so the validation is successful. Press OK. And the moment you do, the first thing which will change here is it will now be a key; it will no more be a date, and there will be no more auto date hierarchy. Auto date time intelligence is gone. Is it joined with our table? No, it is not joined. Look at again this date, sales date, and if I scroll down here, sales date will have a hierarchy. So we have a sales date with which I want to join. Let me drag the date of the date table on the sales date, and the relationship is created. Now I need to make sure the two things which I should have checked before: one is the date, the sales date doesn't have a time stamp; I need to make sure that, and second is the date table covering all the dates. Now I'll go to the table view, and inside the table view let me go to the sales table, and here I have my sales date. How do I ensure that there is no time stamp? So usually what I do for that is I change the data type to date time, and I take a format where I can see a time stamp. All the dates should have a time stamp of 12:00 a.m. All the dates in my case have a time stamp of 12:00 a.m. Any date having time stamp other than 12:00 a.m., it means the join will not be successful; that is there. I can change it format back to date, and I can keep it in the short format, so column TOS help us in that.
Now let's go ahead and check: do we have the complete set of dates? Now we may have multiple tables, so the one of the ways is that you take the Min and Max of the dates and check it out. One of the easiest ways to do that is create a page, bring date or some from the date table, a bring a measure or some aggregated column from your facts, one or more fact. The moment I bring in, let's create a table visual; you should not see any null dates ending s dat. I'm not seeing all date; it means all the dates are joined. And I'll tell you one example where if the dates are not complete what would happen. So let's go to our date table, and we are using the Min date here. Let me use a date which is 2019-01-01. Now I have data from October 2018, but if I make it 2019, what would happen? I'll start getting a blank. So this blank means the dates are missing or there is a time stamp join problem; there's a date time. If you see this, check out those two things. Now let me complete my date table; I can make it from the starting of 2018. The moment I cover all the dates, you will see I do not have blank date. When there is no empty date or blank date, it means we are fully covered. You may have more than one fact; add all of them and check it out. So time intelligence setup is correct. One more thing which we need to ensure is going to come when we create a time intelligence measure. When we create a time intelligence measure and we want to use it, we need to ensure the measure should use the columns from the date table or the period; the visual right now you can see the visual is using date from the date table, and the slices and filter should also be on the date table. That's the way when it's going to work best, which we are going to check after our first time intelligence. Before I do that, once again I'll click on the date, go to the column format, change its format to date, and we'll also change it to short format, so that whenever I'm creating visualization I get little bit of space when I'm doing some work. So let's start with time intelligence now.
As part of our journey, we are going to learn MTD. MTD means month till date; means from the start of the month till the date which we have selected or the till the date which is available in the context. The date could have been selected in the slicer or available in the row context; based on that date it should give us the data for that. For MTD there are many ways you can achieve it, but first of all we will learn DATESMTD and TOTALMTD functions. DATESMTD function need to be used in a CALCULATE function; TOTALMTD function might not require a CALCULATE because it can take a measure as well as the date to give you the total MTD. There are two functions, and later on when we progress, when we go to quarter till date and year till date, we will only start using one of them. So the function is TOTALMTD and DATESMTD. I'll start with TOTALMTD, which is basically a self-sufficient function; it doesn't require CALCULATE. Let me click on the measure table, and I can see the table tool as of now. And inside the table tool I have a new measure option which I'm going to use in this case. Let me click on new measure, and here I'm going to create my first time intelligence measure, that is MTD net, and I'm going to use TOTALMTD. TOTALMTD requires an expression, date, and filter; it can have a filter, and if you need more than one filter then you can again use CALCULATE on top of TOTALMTD, otherwise TOTALMTD doesn't require CALCULATE. What is the expression? So expression, date, filter. What is the expression? Expression is measure, dates is the sequential date where we are going to give the date column from the date table, and filter as of now I'll not give; I'll give my measure net for which I want the MTD, then I'll give date from the date table, and no requirement of filter as of now, so I'll continue with this. I created my first time intelligence measure, MTD net, and let me bring in here. Now it is from the start of the month. Now on the month of October 2018 we don't have the data which is starting from the first date; is 13th October 2018, and that's the date from where the aggregation of the data would start, and till the last date of the month you will see the data is keep on adding. As you can see these two dates are getting added on the next; so we got 36 on 3 days. Now it is 73; 3 days getting added, and it keep on increasing till 30, 1 which is the last date of this month. And on the 1 November, the first date of November, you see there is a reset, and this is what we call MTD start point. You start MTD from the start date of the month, so the value of the that day and MTD would be equal, but on the next day it will start increasing. So on the second you have sum of first two days, on third you have first 3 days, fourth you have sum of first 4 days, and keep on going till the month and date, and you will see another reset happening on the 1st of December; till 31st is going to end, on first there would be a reset.
Now MTD works based on the date in the context. Now date here in the context is basically the date in the row; there is nothing coming from filter context. Let me bring in month here in another visual; I'll drag it into empty space; sorting is correct, and let me drag in MTD measure there. In this case, when we use month here, the MTD measure is going to give us the last dates value, and it will act like a monthly value. If you're using at the month level, the MTD will act like a monthly value at the month level; from first to last, that's the monthly value; it's a current month; the month in the context. We have not talked about the filter as now; how does it behave with respect to filters? What happens when we apply a filter? So now the case when the date is available in the row context, and even if you apply filter, let's say I apply the November filter. Now we know the other visual can also act as a filter. When we apply, you can see only November month data; we can't get more than November month data unless we follow the tricks, and the data will start aggregating for that. You may have a date filter, specific, very specific date filter, on that date filter how much data will I get, on that day's data or the MTD data. So let me bring in a slicer for the date; I'll bring the date in between, convert it into a slicer, and let me go ahead and change this slicer setting using the format which is available on the right hand side, and slicer I would like a drop down, and when I drop down I would drop down actually go a little bit down, I would like to select something in November, so let me select fourth November. So as you can see the MTD value is for the 4th November till from first to fourth, even if the date is not selected; you can remove the fourth number context, okay, but the date from first, second, and third, no, is not selected, but still it is going to get that and give you the MTD value if the value are available in your data; the fourth number is going to give me that value. Now we understand that if you select a month, the dates in the context is going to control that; we selected more than if we select a single date, that date is going to play. What happens when both filter and slicer context are missing? So let's make sure there is no filter context and there's no slicer context right now. Now there is nothing selected on the slicer, nothing select on the visualization, and we remove the filter and the slicer context, and now we will bring in MTD into a card visual. Why we are seeing a blank? What is the date is getting for us? What happens? These TOTALMTD and even the DATESMTD function going to follow soon, it takes the last date available in the context of what the date which is supplied here, and what is the last date available in the date column. Please remember it's only for MTD functions; for the previous they take the first date. If you go to our date table, the last date is today; I don't have any data for today, and for even for today's month my data ends in 2020; we are in 2024; I don't have any data for the current month. What date range exactly it is taking for that, I'm going to give you an example, and let's try to use DATESMTD. Let me do a little bit of visual adjustments here, so I'm going to create my second measure, time intelligence measure; it's again going to be the MTD measure, so this time I've clicked on a measure, so measure tool is visible, and from the measure tool I'm going to create a new measure, and the measure is MTD net1, and this time I need to use CALCULATE. CALCULATE net; I'm going to use a function DATESMTD. DATESMTD actually required only one argument which is dates. This is also true with the next function which
We are going to use IS dates QTD, definitely dates YTD. We can have two arguments: it does cover the year and date, which we’ll see later; only one date; and the date date, which you provide. It’s going to pick up the last date from that, and based on that, the last date. So what it is going to do is it’s going to pick up the last date from the context. Now, the context could be the filter context or could be the row context; or if there is no context available, it’s going to go till the last date of the calendar dates which you are supplying here, and going to take that out.
Dates MTD actually return, return me a table of dates or a sequence of dates. Based on the date in the context, it’s going to return me from the start of the month till that date; a sequence of date. It’s going to come up; a set of dates; month up to current date; date of date. And never; most of the people understand it in the context of today. Today, you cannot pass; first of all, it needs a sequence of date; you can’t pass today to a date 7 and date where what is there is defined by the context. So we given date of date; what is filter context or what is row context; otherwise, what is the last date. In case of MTD, it could be the first date in case of previous functions. So, and this function will also help us in understanding what we are getting. So again, the same results. So dates MTD and total MTD; their uses is a little bit different, but they’re going to give us the same result. Again, we are getting the month till date data using this one, and the same behavior at the month level; there’s no difference. So it gives you a sequence of date from the first date of the month till that particular date; the set of date. And to understand that what we are getting and what we are getting; why we are getting this blank; and let me bring in the other one also as a card visual. Let’s create a table and see what dates we are getting. So let’s click on any of the table and create a new table, and in that table we will see what dates we have using dates MTD, date of date.
Now, because the table is static in nature, it is pre-calculated. The only thing it can do is go ahead and get the last date, because it’s not going to follow any filter context; any row context; it’s going to get the last date in the calendar. Based on that, it’s going to calculate that. And let’s go to the table view now and check what does this table contains for us. And as you can see, the dates table contains the date of the current month from the start date, and this is because the calendar is ending at today. Now let me change my calendar; don’t think that it gives from today. Let me change my calendar. I’m changing my calendar, and now it is no more going to end on today. Let me end my calendar on date 20211231. Again, have data till October; I’m ending it the 12th month. And now let me go to the dates table again. You see the data is from December 2020, and all the dates; 31 dates are available. The reason for that: it taken that last date available in the calendar and calculated it. So these are the date applicable, and because of that you get these blank values. Now you understand; now you know how to play around with; how to control that. So this is what we have to continue.
So now we have learned MTD. Let me rename this. QTD, total QTD are the functions to achieve quarter till date. You have understood by now that the total QTD function is one which might not require CALCULATE, while DATES QTD is going to require CALCULATE to do the calculation. Let’s start with QTD functions. Again, total QTD, DATES QTD; two options are available. I’ll go to quickly create that. So let me add a visual here; date. And this time I’m going to add date because we know its behavior; how it’s going to behave after this one. So we’ll quickly create the two majors, and the two major which I’m going to create here is QTD majors. So QTD net; first of all, with total QTD; again, three arguments: expression, dates, and filter. We are going to pass only two as of now. Expression is net; dates is date of dates; that’s all. Let me also add one more major based on the QTD net 2, and here I’m going to use DATES QTD. It’s going to give me the set of dates; date of date. Two majors going to return me the same results; just implementation difference. What does it do? Start from the first date of the quarter; the first date is not available; first available date of the quarter; and go till the last date of the quarter. The last date of this quarter is 31st December, and it’s continuously increasing in this direction. Values; you can see the daily values are increasing; where they will reset; they will reset on the first date of the quarter. So you can see the November has started till the values are increasing. Let’s go on 31st December, and we have 31st December and 1st January together. Now you can see it’s increasing till this date, and post that it is changing. Now to understand this increase, let’s also bring in net into the visualization. And as you can see, on the first date of the quarter the values is same as that day’s value, and this is going to be true for every start of the quarter; not start of the month. Now if I go to February, there is no more a reset at the month’s start; the value is not same as the value on that day for the second month, because it’s a quarter till quarter and date; it will keep on increasing.
So we got now QTD. For YTD, we are going to use DATES YTD and total YTD. Total YTD might not require the CALCULATE because it to have a capability to take a measure and provides you total YTD along with the date column provided for financial year. In both DATES YTD and total YTD, we can provide a financial year end date, and they can calculate the financial year till date values. Now let’s bring in YTD. We are going to bring it into the same visual; for that, again two majors, and you will notice one difference this time when we calculate YTD. So YTD net; let me start with total YTD. Total YTD; again, we require expression, dates, filter; but there is a year and date. Year and date means if your financial year is not ending on 1231, you can give any date on which it is ending, and based on that it’s going to start. The year end date is only for the reference where it year ends; can get the year starting point based on that, and can calculate your YTD based on that. So here again for the first starting I can avoid the year and argument, and I’m going to do that. And let me calculate total YTD, and that’s going to give me YTD. Let me bring in the YTD using DATES YTD. So NET YTD net 1 equals to CALCULATE net, DATES YTD. And DATES YTD required dates and year and date; it’s required two arguments: date of date, and second argument I’m leaving. Let me add it to the visual. If the visual is selected, I can simply click on that. I got the YTD value. Now where would the reset happen? See, because we are starting in a last quarter, so we will see the reset on the first January itself. Here the quarter value and the year value same doesn’t mean that it’s going to be always the case, and there is only a reset happening at this start of the year. Now in the entire year you will see the continuously values are increasing till the time we reach the end of 2019, and you can see here the max value reached here, and there is a reset which is happening on 1st January 20. So YTD get reset on that day. Now because it was asking end date, it does mean that we can change where it should reset. So let’s say you want a financial year ending on 331st, we can do that. So let’s create a YTD for FY, and we can call it FY YTD net, and I’m only going to use one function for that as of now; both the functions can do the same job for us. And here in the DATES YTD we are going to use the second argument now is year and date, and this is not available with other TDS; month and quarter only available with YTD function. And let me add this. Now let’s look; the value looks same, but we have to pay attention on 1st January, because on the 1st January this YTD is not going to reset. So this, this is resetting; this is resetting; this is not resetting, because it will reset on 1st April when we cross the year on 31st first March. So when we cross year it is getting a reset, and the value is same as the start of the the quarter. In this manner we can create Financial year till date from the start of the Year till the that particular date.
Now let’s learn how can we get the previous month value; previous month till date; and previous month. Why I’m talking about two things, I’ll tell you in a short file. Let me duplicate this page. After I duplicate, I’ll remove one one major from here; I don’t need two YTDs; one YTD is sufficient for me. Now I would like to bring in the last year month till date. So definitely I need MTD function for that, but other than MTD I need to make sure that I go one month back. And to go one month back, I’m going to use a function which is known as DATEADD function. The DATEADD function is going to help; again, DATEADD function require continuous set of dates. So let me go ahead and create a measure and tell you how do I; let me add a new measure from the table tool, and this measure I want is LMTD; last month till date. So I want LMTD net; CALCULATE net; that’s the same thing I’m doing now. Here comes the difference; DATES MTD; that’s same; but inside the DATES MTD I want the entire dates to move a month back. I’m going to use a function DATEADD, and please remember the understanding of DATEADD; that DATEADD also require continuous for dates; please watch DATEADD video on my channel for that. So dates require the first arguments is dates; date of date; this the second argument is interval; how many intervals I want to go to last month; so minus one; plus one for next month; interval: day, month, quarter, year; I need month here. What I’ve done here is basically the continuous argument which date argument which I passed to my MTD has been moved a month behind; it is still the continuous date but a month behind. Let me press and enter here; my major is created; let me bring it inside the visualization; one here and one on the month here. So I bought the MTD in the table which I have dates, and you can see exactly after the 1 month the MTD has started and it increasing in the similar fashion. Now go down and pay attention on 30th; what value we are getting on 30th. I’m getting the value not of the last day of the 30th October; 7 547 K; 547 is on 30th October, not 31st. When I’m using date by date, it take the 30th value; but look at here what is happening at the month level; at the month level it takes the complete value. So MTD used with a trailing date using DATEADD is going to give me the last month value when I use the full month value and corresponding days; MTD month till date of the last month; on that date whatever date I have on that days of the last month what was my value; it’s going to give me that. So this is MTD for me. Now I will tell you one more function; that function is going to give us previous month; and the function which I’m going to use is name itself is PREVIOUSMONTH. So let me create a new majure; meure tool is open as of now; I’ll click on new measure; CALCULATE net; and the function I’m going to use is PREVIOUSMONTH. PREVIOUSMONTH required only one argument; that is date; again, when we use year it will require more than one argument; you can decide the year and date; date of date I’m supplying; and I’m completing this. Let me bring in this; observe the difference which we are going to get here, and you might have realized the moment I dragged it in the visual which contains only date is actually not the single day value; it’s the complete last month; even for each date the next month; while on the month level I’m fine with having a value which is month and date value; it is not suitable for MTD, and definitely this is not a function for MTD; this is a function for previous month; it gives you complete previous month. So now you understand how the MTD trailing can be done and how can we use PREVIOUSMONTH. I would like to bring in something here now. Let me bring in LMTD here, and as expected it is blank. Let me add thee also here; both are blank; you that’s expected, isn’t it? Should be blank. Let me go to the last available month is October, and if I click on October what should happen; should give me the September value, isn’t it? Yes, it is giving me value; this is my value of the SE number; that’s fine. Now let me do one thing; let me play play around with my date calend; I go to my data in my date calendar; I will go ahead now; I don’t want to pass a filter or a filter context; just want to go ahead and change this date to Uber; and as you know I have data enough. Now there is no filter; there is no filter context; and the date is ending at the last month where I have the data; see I have the data for October; that was the last available data; and this is my previous month data; and I’m getting a previous month also in my visual; make it a little bit bigger; overlapping; as you can see; see here I’m still getting the previous month values both with the LMTD and B previous; but look at the the card is not getting a filter because I have not clicked on any of the values nor I have used my slicer; so there’s no filter context; there is no row filter context; there’s filter context here available with this visual which is containing month here; so there is no filter context for the card visual; there is no filter; why it is giving blank; why not September? Because LMTD is giving me September; MTD is giving me value; why PREVIOUSMONTH is not giving; the reason for that; that PREVIOUSMONTH and all the previous function which we are going to use whether it is previous quarter and previous year; they use first date into context; they don’t use last context; and to understand that let me give you one example here that it is using the first date. I’m going to bring in month year as a slicer here, and in this month year slicer I’m going to go down and select 2 months; January February; January 2019 February 2019; the ones which I selected; what are you expecting; January to get the December value; seems like it is getting; and February to get the; like it is getting; what what value; what value is this; LMTD is giving me January and PREVIOUSMONTH is giving me De; this is because in the context there are 2 months right now; and the LMTD is picking up from the maximum available because of MTD; and PREVIOUSMONTH is picking up the first date available because there is no filter context; only filter is available; and filter is giving 2 months; you need to be really careful if you are designing a previous month or the last month and you’re using these function and you select a range which is crossing a month; you’re not using any context then the behavior of these functions can change; so keeping in that mind you should create these majors and use them appropriately.
The next thing which we want to learn in the time intelligence is week over week; week over week. The challenge with us is basically that there is no standard function for that; we need couple of things in our date table. So let me go to the table View, and in the date table let me tell you what we need. So in the date table we will need a date rank which we have created as a column here, and the date rank should be the ascending Rank and it should be dense; means after one we should get two. I have created that on week start date; you can also create that on year week YY y ww. Second thing which we need is the; we need a week day as a number; and the week day when we use the weekday as a number that should follow the same week which start date is falling; so we don’t have a week day as a number. So let me add weekday as a number here; I’m going to enter here; let me call it weekday number; and weekday number should follow the same weekday which start date is following; so what start date is following I’ll let you know; week start date is following this one; so same I will follow for weekday; usually for the Monday start what do you want; so two is for Monday; 11 is also for Monday; so Monday; weekday number one for Monday; and I’m starting; let me sort this for sending; 1st January 2018 was a Monday; so that’s correct; and and we have a week rank of one for that; 1st January 2018 is a Monday and it should be first week also; both the informations are correct. So now using this we will do our time intelligence. So let me add a new page, and what I can do is directly I can start with; first we will do week over week and then later we’ll do WTD; week till date. So for that from the date table let me bring in week start date, and using that only I’m going to bring in my week over week. So what is going to be my formula? So here I’m going to take the help from the row context. So this week is the major which I’m creating; CALCULATE net; then I’ll start my filter. Now in the filter I’ll use ALL. Now for this week I can use ALL; selected; assumption is that this week would always be present; but it’s Finly possible that I select a date and I need the complete week; then that’s why I need ALL. So in ALL I can give table or column name; I’m going to give table name here because I want to ignore all the filters whether it’s a day month year quarter; and then I want to use date of date; tables week rank equals to MAX of week rank. Now what does that means is when we use the MAX of weak rank in the context whatever week is available or a date is available for that is going to find out; let’s say even month is available; able then it would be the last week of that month; here is available; last week; and if the there’s no context available; last week available in the date table it would be picked up. So this is how this is going to behave, and it’s going to give me this week measure. And let me bring it inside the visual and convert it into date table, and you can see that the values have started from the very first week; the first week started on 13; so the week of 8th contain the 13 only two days of data; and then we have the week of 15th and the week of 22 for which we have the data; and I can showcase you it with along with the date also. So let me bring in another visual with date, and this week value will repeat for a week because we are doing this kind of calculation. Now last week calculation is very simple; we have to use this week’s calculation but when; so CALCULATE net; filter ALL the date; means ignore all the filters on the date; we rank should be equal to the MAX of week rank but minus one; it should be minus one; and because the entire date context is available; entire date table is available; we’ll be able to have the last week also; last week; the only difference is this minus one. Let me bring last week also here, and as you can see the last week values are now av la. So we have learned this week and last week; how do we get week till date? For week till date remember you have to use week number; don’t use date; you will use the same formula as this week with the difference; copy the same formula of this week; create a new measure; Major Tool is open; new measure.
is available there. And now we are going to create what we call as WTD. Be till date again; no standard power BI function is available, so we'll filter the date table. All the dates, week rank equals to the max of weak rank—means whatever is available in the context—and weekday number equal equals to Max of weekday number. So whatever is the weekday number, it should be equal to that number; that is what we are going to have in the filter clause. Week is equal to week, and weekday number is also equal to the weekday number, but that's going to give me the weekday. I need to use less than equal to. So now it is start accumulating, so all the week days we have to consider. And let me add this; this will give me WTD. And you see that the two days are adding, and this was the value for the first week. Then there is a reset which is happening. Let me bring in net, and when I bring in net, you will understand that these two days are adding here, and this was the same value which we got for current week also. Then for the next week, these values are adding till this place, and this was the value which we were getting. These values are C for the week is getting added, so we got WTD. Now what we need to do for last week till date? Very simple; this is the same last week formula you need, so I can copy the WTD formula; actually that's much easier. I copy this WTD formula, create a new measure—measure tool is available—new measure is available there, paste this formula, call it as last week till date, and the only difference is only where the weak rank is there; you just say weak rank minus one and press enter. You got last week till date. And what would happen here is when you add this to the visualization, you will see after a week we got on 13th, so on 20th you will get a value. On 21st, the next accumulated value will come, and whenever there is a reset, there would be a reset. Whenever there is increase, there would be an increase. Now next day is again Monday, so you will see the same value as the week start which is coming, and so on it will keep on adding post that.
So now, in spite of not having a function, we able to get week till date and this week versus last week. Any custom month, whether it is half year, whether the month is 28 days, whether the month is starting from 15th of a month, as long as you are able to create a weak Rank and day of period or day of month, the same mechanism will apply for period versus last period, month versus last month, and MTD versus last month MTD or PTD versus last PTD. So till now we have learned, you know, we have MTD; how to get last month till date? You have complete month data; how to get the last month complete month data? Similarly, we have done for quarter year, and then we created some custom formulas for week. We have not discussed a very simple thing: what happens when I want last days data? What was my data 7 days before? What my what was my data a year before? Or a week year before? Week year means 364 days. Today's Monday; what was my my data same Monday last year? How can I achieve this? So for that what we are going to use? We going to use the date add function, and we are going to create certain trailing formula. The name trailing is coming because they are behind by certain days or days behind formula, as you can see. So I already a new page, and in this new page I'll add date from the date table, and this time I don't want aggregation above the date level; means I don't want to aggregate for TDS till date. I just want this is my net; what is my net for last day before, 7 days before, a year, even it could be before a month. So let's quickly create some Majors. So on the Home tab, new major is visible as of now, and I'm going to click on that, and let me create last date. So this is going to be a date add which I'm going to use for last day, but we do have a previous day function which is available. So here I'm going to use calculate net, date ad, and in the date ad there are three arguments required. The first argument is date of dat, second is minus one, and third one is day, so it is going to trail by a day. I got last day. Values are just a day behind. Now let's create last week. Last week is basically 7 days behind last day. Last week same day which is a week behind, so it's going to be behind by 7 days. So Monday to Monday, Tuesday to Tuesday, Wednesday to Wednesday comparison we, and let me add this into the visualization, and as you can see the values are a week behind. So this is 20th; this was 13th. Same way 21st, 14th, a week behind. Now how do I get a month behind value? Simple; create a new measure, and instead of day use month and minus one—minus one month behind—and same last month same day. You will see on 13th of November I'll get my value. On 14th of November I'll get my 14th of October value. I getting a month behind value same day. I can do for quarter, but I would like go for year and last year same day. So basically what happens is every year typically we end up adding one additional day. So if it is 13th next year, it is 12th. If it is not a leap year, next year it is going to be the 12th October which is going to have the same weekday. 364 is the combination which fits in the proper division of weeks, so 365 add one additional day. So because of that same week day last year if I need, so last year same week day I'm going to call—I'm not going to call same day—I'm going to call same week day, and here instead of subtracting a year I'll subtract minus 364 days. And usually on the non-leap year you will find it is a day difference when the actual data comes in. In case of leap year it could be 2 days. So remember the value for the 13th of October and 14th of October, and when I go to the 2019 I will start getting values from 12th of October, and the reason behind is the day. And let's bring in week day into the picture now. Now let's look at what it is—Saturday; what this is—Sunday. Let's scroll up and see what we had initially—Saturday and Sunday. Now you understood why we have done that. Now last year same day basically it is 13th October; I need 13th October, isn't it? In that case I am not going to use -365; I'm going to simply use -1 year. Don't use 365 or 366, nothing like that; just subtract one year, and we will get last year. And when we scroll down you will see the data is actually started coming from 13th of October. Sunday; every year the date will change, so this year it was Saturday, next year it was Sunday. This is how it is going to happen. So this is how you create trailing formulas. Now these formulas are a day behind. Again, sometime what would happen like if you have too many dates available, your grand total may actually not be a year behind. So if you don't have a year in the context, then what would happen is, let's say I have a calendar which is still 2021, so what happen? My calendar is actually trail, let's say for minus one year formula, my calendar even get trailed by one year when no date is in the context. I reach 2020, and I have data till 2020, so my values could be same for the trailing as well as this one. And that you will see for the last day the grand totals are same because I have additional day available for the same week day. It is again same for month definitely because we ended on October, so that is why we have a little bit less value. But if I increase my calendar dates, you will you will see these dates are—you will see if I move it by to December or let's say October 2021—you will see that the values of grand total is now same, and the reason behind that that when the context is not available or the filter context is not available, it moved the day a year behind or a month behind or a quarter behind, but still it has covered all the dates which are available. In such cases if you're using, make sure either the context or the filter or slicer is adding a year to the page or to the visualization so that we get correct values, otherwise you end up getting incorrect values.
In Power BI we have many DAX function, but starting from December 2022 we got a series of functions which are very similar to SQL Windows function. Now the reason we call them very similar to SQL Windows function that they do also provide us something known as order by and Partition by, and based on that we can do certain calcul which were previously difficult to do, and now they are very easy if we use these functions. So what are these functions? Let's have a look at it. In December 2022 we got three function: offset, windows, and index, followed by two more functions in April 2023; those are Rank and row number. All these functions are on very similar basis; they all have order by, they all have Partition by, and they also support access and reset. Now what are the key highlights of these DAX functions? So these DAX function, as I already told you, are very similar to SQL Windows function, performing performing calculations across related table rows based on DAX evaluation context. But unlike Windows function, these DAX function do not return a single value, but a set of row which can be used with the functions like calculate and SUMX to compute the values; means they are not going to return single value, so we have to go ahead and use different function like calculate or SUMX to make sure in our measures we are able to get single value. So these function execute in DAX engine rather than being pushed to the data source, offering improved performance particularly when sorting by non-continuous columns. So basically what happens is their execution happens as the DAX engine level, so they will be able to provide you better performance. So these functions are different, and they are executed differently to give you performance gains. Key highlights, as I already told you, these functions use order by, Partition by, access, and reset. Typically they are used in pair: order by and Partition by one pair, access and reset. Access and reset are usually used in visual level calculations.
So let us start with the offset function. Offset function is one of the functions which has been released in December 2022, and it's very similar to Windows function, and now we're going to use that. So let me start first by creating a visual on category, and I will take along with the category net. Let me convert this into a table visual. Now here I would like to know what is the value of previous category. Now based on what? Based on the category sequence or based on the net sequence? Okay, so in this manner we can comparison; means based on the last one which, and that's where the offset comes in play where we can actually go up and down. Now offset is not a table function where it goes for a table row; it still need the context; means by which you are—it needs that row or group by for which you are going to move up and down inside the calculation. So let me add a new measure, and this measure is I'm going to call offset one: CALCULATE(NET, OFFSET. Now what are the things we require for offset? Delta plusus one; what is relation? This should contain the columns for order by and Partition by. With the enhancement you don't need to add Majors now, so if you want to use a major into the order by, you don't need to add it. Then you have order by blanks; most of the time we are leaving that blanks. Partition by where you can—means let's say if I want to partition inside category or brand—see the operation should happen within a partition; we can do do that. Then we have concepts like match by and reset which can also be used. Now let's start with minus one offset, and we will use all selected. Now all selected and all depending on whether the data which is present based on that we want to take a decision or data which is also not present but present in the values want to take decision based on that. I would like to take based on the data which is present, so item category order by. Now order by let's first start with item category itself, isn't it? That what is the value for the last category: 1, 2, 3, 4, 5. Rest I don't need; I don't need Val blanks. Partition by, match by, and resets. So let's close the offset, and let's close the net. By default here order is ascending. Now in Power BI, those of you who have seen rank, you know that the by default order is descending, but for all the windows function the by default order by is ascending. So let's add this mejor offset inside our our visualization, and let me sort it on category because that's is how I've done it. So as you can see here the net is trailing by one one values because I given offset one. Same way you can give offset 2, 3. This is minus one. Okay, now either I can make it plus one or I can change the order; that is one of the two things I can do. So let me do one thing; let me go here in order by, and let me use descending. What would happen? Instead of trail by one, now it is lead by one. So Category 2 is coming in category one. So next. Now same thing you could have achieved by ascending by using plus one. So I removed the descending, and let me remove the minus one also. So same result I got. So in this manner offset works. Now this is one way variation of offset. Now let's run on the second variation of offset where now I don't want to sort on categorical values. Now this would be really useful when we do month-on-month comparison, but let's look for the comparison which is basically for net. So I want to travel by net; my top category I should differentiate with second top; second top with third top. Now comparison is happening between the top ranks, then how do I do that? So then what would be my order by in case of this new major which I'm going to call offset new? I don't want to do by the categories; I want to do by net major, and see I have not added the major inside my all selected in relation; it is not added, and let me use descending and let. Now let me bring this inside. Now I need to sort it on net to understand this. So category. Now why I'm getting in category 4? Because I used plus one; I said in descending order plus one, but in descending out what I need? Minus one. So now the topper would be trailed; so second topper will get the first topper in this value. So now whether you need second with first or first with second you can decide. Now this is really helpful; the offset is going to be really helpful in month on month comparison, quarter on quarter comparison, and year on year comparison. Now let me do one thing; let me bring in a new visual for you, and in this visual what I'm going to do here is I'm going to do a little bit of trick. So what I'm going to do here is I will bring in year, I will bring in quarter, I will bring in month, and I'll bring in net, and let me instead of month number let me bring in month here. What I want here first of all? I want month on month. So how do you get offset of month on month? Very simple. Challenge: month on month is a text; it's not going to work easily. So I would like M and offset month on month offset. How do I get? CALCULATE(NET, OFFSET. What is Delta? Minus one. What is relation? All selected. Now here comes the challenge: month is a text, and it's order is not correct, so how do I take this? So here what I'm going to do is date table month year; I need to take month year as well as I'll take month year sort. Let's take both of them: month year and month year sort; both we have taken. Now we will go and so relationship is done. How do I sort? I need to sort on or order by on month year sort. Do I need to partition as of now? I don't seem I need a partitioning, but we may or may. Let's bring this M offset inside the visualization. So what we see here is basically that we're able to get this month or month, and let's not look at the quarter and this one because quarter offset doesn't seem like this. TW first of all I should not have got anything here in the Q4; I'm getting something, so we are not looking, but here in the month things seems to be correct, but there is a challenge: I'm not getting this one for first month. So let me change this visual a little bit, and let me duplicate this for this. So I've duplicated it, and let me delete this first visual; I don't need. But if I use here this visual, I duplicated it, and let me remove year and quarter from here. You can see that this measure has properly worked, isn't it? For every month I able to get an offset minus one offset easily; M is working perfectly fine. Why not here? And this is what we call the inclusion of all the participant in the formula. So what's happening here is basically the quarter and year are also the participants which are not been considered. So even though we have not done the partitioning inside the quarter and year, auto partitioning is happening, and that is something you might have seen in the rank function also. So now what we are going to do is we are going to include that. So we'll say, Okay, include the quarter also, so DATE[Quarter], and include the year also, DATE[Year], and the Sorting don't need to change because the Sorting month year is still valid across these. Month year sort; we have taken month year sort; it is not month sort. Now what you seeing here? What we see here is okay, this is fine; this was previously also happening. Now this is also happening. Now across year and quarter we are able to get M, and the month year actually only month year visual also retaining the same. So in both cases it is working. Now you might have understood how I want to get the quarter. Very simple; I'll keep quarter year and change the Sorting of quarter year. Now quarter Year is already in sortable format, so I don't need a sortable quarter here. Here is easy, but tell me will I take three measures, and then how would I ensure the quarter is going to be at quarter's position and month is going to be a month position? And so what I'm going to do is I'm going to create a little bit complex measure this time around. So you understood how offset work, and now let me take this calculation here, and I'm going to take this use this calculation inside a new measure which is basically PO period on period. What I'm going to do is in Period of period I'll create a switch statement: SWITCH(TRUE, and in SWITCH(TRUE I'm going to use ISINSCOPE. When we use ISINSCOPE, we have to remember that the one which is at the bottom of the Hier. So let's consider this Matrix; in this Matrix visual at the bottom of the H is month here. When we look at the row columns followed by quarter and year, year is on the top; month is on the lowest. Whenever you use ISINSCOPE, you should handle the lowest one first because understand year is always in scope other than grand total; quarter is in always in scope other than the year total; month is only in scope for month column. So here year is in scope here as well as here as well as here; here is only not in scope in grand total. We can decide what we want in grand total when nothing is in scope. So now we know our Scopes. So ISINSCOPE, what should be the first one? Month year, and the column which has been taken in the visual is really important, so month has been taken in the visual, and at that time which formula I'm going to use? I already copied that formula, so this formula is going to work. Now second is ISINSCOPE, which should be second?
is in scope quarter so date quarter is in scope. What formula you need? I need almost similar formula, but I need this for quarter. So let's start changing offset minus one, all selected. I don't need monthier columns, quarter and year. What should it order by? It should be order by quarter. See, it starts giving the error if you're not using so minus one is my Delta. My relationship is all selected quarter, year and year, everything which is applicable to this particular row. Okay, relation order by water. Here I don't want partition within here; I want it to go across here, and that's why I'm not taking Partition by, and that's why I'm including the complete combination so that it can go across. So very good, you can copy this formula now. Now you can take a decision whether you want to write down is in scope ear, because if you write down is in scope ear, you have a flexibility to write it down the grand total also, but right now I don't not much interested in handling the grand total, but this is one of the way you can handle the grand total. Okay, now think about it: when we are comparing month on month, quarter on quarter, year on year, and on what I'm going to compare on the grand to do, I really want to compare something or not? That is the decision you have to take based on that you decide, and there's nothing in the context of the grand total; there's no year there, there's no quarter here, so what is going to trail that is also an important question. Okay, so what we saying calculate now ear is in the scope or gr R is in the so assume the year is in the scope, so I only need ear; I don't need quarter; I don't need month, and what it should be order by? Year. My year is number which is sortable, so I handled all three conditions. So what we have done is we have used this season scope, and using this scope we have now created a calculations which is going across month, quarter and year, and three different level it is handling in three different manner. Now we need to understand these calculations, so let's pull in this measor inside this visualization. Now you can see for the first year, quarter and month, there is no value; it shouldn't be, because I I don't have anything before that, isn't it? Month we already tested. Let's look at the quarters, so this value matches with this value of 2018; here quarter matches with quarter. Now when I go to Q2, the value matches with previous quarter. I to scroll down little bit or make this visual bigger, or what I can do is I can move up, so month is removed. Now I can compare year also again easily at the year values. So we're able to now compare month on month, quarter on quarter, year on year in the same visual, same Matrix visual. We are able to do is in scope has helped us; offset has helped. So this is how powerful offset function is, and there could be many things which you can do with this; it makes your travel easy across the rows based on categorical data or a major. So go ahead and try that out. One of the most interesting function in these functions, offset, window, index, rank and row number, is window function itself. Now very similar to SQL Windows functions, but window function is really interesting; it allows you to create so many things: running total, rolling totals, MTD, qtd, YTD; lot of possibilities are there. All the function offers different kind of possibilities, but Windows function has so many things which you can do, and it is because it provides you those two arguments where basically you can decide the position of traveling. So let's look at this function. So let me add a new page, and in this new page I will start with month here this time, because while we can do traveling on the categorical variable other than the time, not going to make much sense unless we have very specific example, and time is a very good example: month, year, and along with that let's have net table visual. First thing is I want a rolling, so how do we do rolling? We have formulas in the past, so let me tell you the first of all rolling formula without Windows, how you let me create a new measure. So let's say I want rolling two, and rolling two is easy to understand, so usually we do rolling tool like usually calculate net dates in period is something we use in dates in Period. What we want a date column? Basically, the first argument is a date column, start date, number of interval and intervals. So what we do is let's say we give have end dat here, so we start giving intervals in negative and then inter well basically month, quarter, year, what you can get this is the date in Period. So what first thing I will use is a date column, so date of date, second is start date, so we usually use max of date of date, means whatever is current Max date you take that, then I'll use minus 2 because I want 2 months rolling; usually we do 12 months rolling, but 2 months is easy to understand; we can easily compare the total. So this is rolling two. Okay, we got rolling two. Let me bring in Rolling two here. Now as you can understand the first one is same because there is no previous month. Now this is total of these two, the second row November, then December is total of November and December. You and see the number which is 18 68, which is very similar to some of these, and similarly you can see because if it's more then it would not have survived; if it is too high then it would not have been 2 months total; it is more than that. So now we understand that it is only totally for 2 months. So rolling is there. Second formula which Windows also easily is cumulative. Now today, how do we do cumulative without using Windows? So again I'll create a new measure and give you an example of cumulative. So if I have to do a cumulative measure, let's say cumulative sales, how do I do? I'll do calculate net filter all of date, so we have to ignore everything which is coming on the date, and then we say and the reason is I I don't want to say that if you have taken the filter of the year then I'll not give cumulative; if you taken filter of the date I'll not take give you a cumulative; or if you have taken filter of month I not. So that's why we are ignoring all the filters on the date, and then we say date of date and this works even for month, quarter end that's why we start with the basic unit of date that I'm doing cumulative for each date, and then it will roll up to month, quarter and Year. Date of date is less than equal to Max of date of date, so in the context whatever Max date is available I will take less than equal that, so max of date of date, and then we close filter and the calculate. We got a new mejor which is cumula sales. Let me bring in this, let me also bring in this inside the. Now in this one you see the total is continuously increasing until the end of time; it will keep on increasing, and even if you don't have the data because your normal measures will stop as soon as you get blank, but this will not stop because it's still getting the data from the past from the beginning of the date. You want to control then you have to give additional filter. So now we understand that you know the basic way of doing these things before the windows function. Now how to do this using window function? So let me duplicate this Visual and remove additional stuff. Now again we'll start with rolling again. New major Home tab is open; we can click on new major there and the major this time again I'm going to create rolling two, but this time the rolling to would be created from Windows function. So let's understand this function. So first calculate net and now I'll use the window function. In the window function let's understand the argument from offset, type of offset, two offset, type of offset. Then we have the normal one: relation, order by, blanks, Partition by, match by and reset from number, type absolute or relative, whether it's absolute or relative. What's happen in case of rolling? Rolling is basically relative minus one to 0, two rows, and what is cumulative? Cumulative is partially absolute, partially relative from the absolute Z row to relative zero. Relative zero is current row, so what happens in this case is the relative position is with respect to current row, so my current row is let's say December, then November is minus 1 and January is +1. So now let's start creating this function, so -1, why not Min -2, because from -1 to 0, two only we are considering which position, relative position, relative to the current one, then what is the next one? I want zero. What is this zero? This is zero is also relative, relative position the current rows relative zero position, comma all selected or all. We use all because even if the data is not present I want to some all month year, so what we'll use in inside this one all month year, but month year cannot sort, so we'll use all month year sort. This is the relation we want. Then what is the next order by? Order by what we can order by only only month year sort, then that is why in the relation we have month year sort. Do I need anything else? No, I don't need anything else. Rename this one and commit it, rolling to by window function. Let me drag this inside the visualization. You can see very similar results here, same rolling to results, so rolling to from Windows and rolling to from the traditional mathod. Whenever we can use Windows function, we prefer the way of calc ation is a little bit different, so it should give us the advantage. Now we want to create cumulative, and this cumulative measure is going to become base of many other measures. Let's see, so how do we create cumulative in case of window? So let's begin a new measure. First of all, measure tool is open, and under that I have new measure, and I will now create a measure cative net using Windows. Calculate net, window function from where I should start from? Or one one absolute till which place I should go to? Zero of relative. I want to go zero relative position. What is my relation here? I can give all data; I want to include the complete date table, then order by order by, and because I have included the table it should allow the order by date. Do I need anything else? I don't think I need anything else right now. I should be able to get a cumulative net using the window function. Let me add this to visualization, and as you can see see it is also showing the cumulative results, continuously increasing and should give me the same total at the end. So on the last month the total is same as grand total, and it will continue even if you don't have data. So similar behavior of cumulative net with cumulative sales from the traditional method, so both traditional method and the window method for cumulative giving same results. Now what we are going to do, interesting thing is we'll take this cumulative method, keep on partitioning it month, quarter and year, and we'll get MTD, qtd and YTD. Very simple, just set Partition by, you get MTD, qtd, YTD. How so? Let me rename and duplicate this window one, duplicate window 2. Now let's remove something which we don't need. I don't think even I need the first visual. We have learned using time intelligence how to do MTD, qtd andt. I'll only going to keep cumulative here in the visual, and let me copy this formula using the major to new major. Let me duplicate it, net MTD window function remain same, 1 absolute, 0o relative, All Dates, order by date, but now we will add after the order by, leave the blanks, Partition by what I want partition? I want to partition it on date month here, so MTD function is ready by just partitioning the cumulative Windows code on month. Does it won't work? Seems like month total, isn't it? Seems very similar to month total. How do I differentiate? And to do that actually we need to bring in one visual with the dates, at least for MTD we need dates, and I'll replace the month here by date. So in the first visual now you can see that the data is getting added up till the end of the month, and there is a reset which is happening at the start of the month. Same way when you and another month totaling up till the end of the month and reset happening at start of theth month, MTD behavior. Let's do for qtd. Copy this formula again, new major from the Major Tool, and just we need to change qtd and Partition by what? Quarter. It should be quarter here actually, and my quarter is actually quarter here. Let's add this to visualization, and now you can see the reset is happening after the quarter, so the first month value is same, and if I look at the day level also you will see that on the 1st January only the reset is happen happening. If I go to first FA, there is no reset for quarter. Now you would have understood ear is really simple; same formula, Major Tool is open, new major, just go ahead and change the name and the Partition by. Add this to visualization, as you can see reset only happen once a year. Windows function giving us MTD, qtd, YTD, running total, ruling total; there could be there could be n number number of such things which you can do using Windows functions, so keep on exploring. Let's start with the index function. The index function can be used to identify top bottom performer, top first performer, second performer by value and name. So let's begin our journey by bringing in category in a visual, along with the category I would like to bring in net inside this visualization table visual. Now let me create a majure which is going to give me the top category. Top by what? Top by the category names or top by the net? I need it by net, isn't it? So top one cat, and I'm going to use the function which is known as index. Index which position? First thing is position, then relation, order by, blanks, Partition by if you need the within, let's say within brand what is the top category or within the year which is the top month? Match by I need the topper one. What is the relation? All item category. What is next? Order by order by what? Net, but ascending or descending? Topper means descending in case of net, topper means descending. I don't need to give next of the argument. So let me bring this inside the visualization. It's giving me the name of the top category, and as you can see the top category is Category 2. So this would remind you of a function top n which can also give you the top category, but the challenge with the top end function is if you say top n 2, N is two in top and it's going to give you two categories, not one. I want the second topper. How do I get that? Very simple, here in the index function uh to Second category and just change index by two. You got the second topper. Category 4 is the second topper. You need bottom performer? Use minus one or ascending; you will get it. If you even put this on the card visual, you will get the results. Now you may be asking why this is repeating? Can we control it? And I'll tell you how to control it. Let's use calculate max of item category, comma, then we will use keep filters; we don't want it to repeat, so we use keep filters on the index, keep filters on the index, and the expression will keep it as it is, so this will work as values and filter, and we will now close the key filters and calculate and bring that in, and as you can see it can now filter the visual if require. So we can duplicate, remove the additional items, and you will see the visual is getting filter, and the reason I use this formula was a little bit different because I actually now want the topper value. What is the value the topper had? So I'll create another mejor, and in this mejor I want the net value of topper, and for that I'm going to replace this Max category by net, so I want to keep the formulas almost similar, and then index is one. Let's bring this inside the visualization. This is the topper value, but if you want to compare with the topper value how much percentage you are of the topper, then what you can do is you can actually avoid using this keep filters. If you Avid keep filters, then this value will repeat for all the categories only when you are inside the category View, and you can compare how much percentage you are of category. Similarly, if you want to know bottom performer, very easy, either use minus one or sort by ascending, one of the two thing will give you bottom performer. So instead of top I now want bottom performer, bottom first, bottom second, bottom third, everything is possible; just go ahead and change the number in the index function, and you will get it. So the bottom performer is Category 5 with the value of 615 K. So offset function makes it really easy to find it; you can use Partition by to find is it within inside a partition, and this function opens New Opportunities while you're dealing with this in the visualization. Now let's understand rank function. You already have a rank X which is very similar to this function, but this function is different in its Behavior, the way it is used, and one of the biggest advantage of this function is it can be used to give a rank for a major by considering a column also, and I'll give you that by an example. So let me first of all find out what rank we already created. So if you remember in the past we created rank on the net, and it was created on brand. Let me bring that ins inside the visualization, and let me bring in brand also. This rank was created on net, so let's add net into the visualiz thought on net, so you can understand the rank patter. So how did I get this rank? So we use the rank X function. Now we use the another function for the rank which is rank function. Rank net, one equals to rank ties. First thing it ask for ties, second thing it ask for relation, which is something which I all or all selected item brand. Order by what? Order by you want to give blanks in case you have blanks? Partition by in case you want to partition the rank within something? Match buy and reset these are the standard things which we have in the any window type of function. It's not true SQL window; it's type of that. What is my ties? Ties is dance. Dance means even if the rank repeat the next rank would be the continuous rank, so 1 1 2, it's not 1 1 3. I can use all or all selected. I let me use all selected item brand. Now order by something which has been enabled only major, so you don't need to have it part of the relation. I can simply give order by net ascending. And rank X was by default descending. Rank is basically the series of function which uses these kind of order by and Partition by. All of them is by default ascending, so we have to use order by descending because we want the net to be sought by descending. Now this function is also better for handling ties, the reason for that is basically in the order by I can simply use item brand. Now if I use the brand name it will immediately break the ties if I have the same number. So breaking tie is really easy in this function. Fun, well that was little bit complicated in case of rank. So rank breaks T. Now I would like to take another case. I go to my sales table. First of all I go to my customer. I bring in customer name, t date and net IND visualization. I first sort it on customer and second s with the shift button on sales date. I want to know the first sale of the customer. So here what I want to do is I want to rank the customer sales States. I don't want to rank them by net; I want to rank them by sales State. Can I do it in rank X in the r rank expression where we use the major? You can't use a column if you are creating a rank major in a rank column; you can do that, but not in a rank major, and that's where the rank function comes handy. Unlike rank X where you can use only a major in the expression of a measure, rank functions allows you to use a column also. How? Let's try that out. New measure from the Home tab.
And I'll create rank customer date rank. What I need ties then something is repeat. Use dance relation is really important here, and I'm going to create this relation using summarize all selected sales because the things are coming from two different tables: customer, which is a dimension to the sales, and the sales date, which is coming from the sales. That is why I need, and I need definitely the all selected or the all data, and that's that is why I'm using all selected on the sales inside the summarize.
From customer, what I need? I need name. What else I need from the sales? From the sales, I need the sales date. Now comes the order by. In the order by, what I need? I need order by of sales date ascending. I need ascending rank. Blanks I can leave empty. I need Partition by customer, which is customer name. Partition by customer name. I don't need match by, and reset I can leave it.
Let me bring in now this measure. Let me bring this inside the visualization. Now, as you can see, as you can see, we have a rank of part the Sal State inside each customer. This is something which is not possible using RANKX function. Also, you can easily break ties here by including additional parameter to order by.
Let's start with the function ROW NUMBER. Now, ROW NUMBER function can provide you the continuous sequence of the number or a visualiz. Now, for quite a some time, some of you are asking, let's say I'm creating a table visual, and in that visual I would like to give, you know, sequence number. How do I give that sequence? So this function is going to enable that. I'm going to take a little bit different example and measure. So what I'm going to do here is basically I will bring item name from the item table, and I would like to bring from the sales table the sales State, Sal State, and now I would like to bring one major NE.
Now here I want to create a row number. What would be row number based on? Row number can be based on any of my condition. Let's say I say first item and then order by sa State, and then if really I can consider the net, or it could be based on net of item and Sal state. So we can decide the criteria the way we wanted to do it, and based on that we can create. So let's start a measure. So I'll call this as row num and use the function ROW NUMBER.
Now let's look at the syntax of ROW NUMBER. First of all, it is asking for a relation, then for order by lengths, Partition by, match and reset. So relation means it should include the columns which are there in the visualization which want to consider. Order by, how do we order that by, and blanks. So now let's start with. So I'll use all selected because I want the item and sales date whatever is available in the visualization to use it. But the challenge is item and sales date are not from the sales table. So for that I need to change this code little bit. I need to use summarize function first. Summarize all selected sales. I whenever we take the central table in the star schema, we should be able to use the related Dimension item name, comma is date. This is what I need. Order by what? So I'll use order by. Let's use that. Partition by, I don't need any kind of partition. I want the continuous R number. So let me add the r.
Now you seeing the numbers definitely not making sense to us. Okay, so let's sort on the net. So when I done the sort ascending, and because the sort is by default ascending, you can see you are getting the r number. Now here we did not talk about TI Breakers. It did not say order by net then item then sales dat. No, it's automatically broken those ties. Let me do instead of order by net, can I use item? Item name. We do that. Let me sort on the item, then higher automatically breaken taken care. It's acting as a WR number.
Now let's take a case. What happens if we forget something is there in the visualization? Let me bring in the ID inside the visualization. You start seeing a repetition, isn't it? Why are you seeing the repetition? Now the reason for that is that the city ID is not considered inside the relation. So let's add the city ID also here. Sal City ID, whichever City ID you taken geography Sayes, and immediately you see the row numbers are correct again. And if you forgot some something, it may not give the correct answer. So whatever is participating in the table basically those which are getting grouped, you need to use that.
Now if you want this row number to reset, let's say after partition, let's say you want this row number to reset after every name, then we can use Partition by name, and let me remove the city because otherwise there are too many items on that, and remove this city from the row number relation also. Order by and now let me use Partition by, and it is item name. Name. I Chang my formula. Now we need quickly scroll down. The best way could have been we should have used Matrix, and now you can see item 10 and item 10. You can see a reset happening in the rank because it's partition inside the item. So row number is allowing you now it can give you continuous row numbers. It can give you within a partition. Just give the combination and you will get it. It's automatically breaks the ties. You don't have to explicitly do it, but yes, if you want to do use order by to break in a particular order.
So another function, set of five functions as of now, which is OFFSET, Windows, INDEX, RANK, and ROW NUMBER, which uses these order by, Partition by, very similar to Windows function of SQL, not same. That has a different objective. It has different objective. Execution wise they are also a little bit different, but they provide you whole lot of flexibility to create the Maes which are really difficult to create otherwise. Let me rename this before I could have completed the editing of my complete code.
February 2024 release has arrived, and in February 2024 we have got visual calculations. So we are going to have a deep dive into the visual calculations and going to look at the various functions available in the visual calculations. These are the DAX function which we can use at the visual level. To understand this, we have to also look at the release notes of visual calculations of February 2024. So unlike other functions, we have not taken you to the release node specifically for the visual calculation functions. I'm going to take you through the documentation. I am on the February 2024 release notes feature summary, and if you scroll little bit down, you will see all the features, and one of the features which has been released in February 2024 is visual calculations. Let we click on that and go to the feature.
So let's read the release notes. A new way of doing calculations has arrived. You can now add the calculation directly on your visual using visual calculation which are DAX calculations. Remember these are DAX calculation that are defined and executed directly on visual. A calculation can refer to any data in the visual, including columns, measures, or other visual calculations. Means you can refer the other visual calculation also. This approach removes complexity of the semantic model and simplify the process of writing DAX. You can use visual calculation to complete common business calculations such as running sum, moving average, etc. Visual calculations make it easy to do calculation where previous the very hard or almost impossible to do. So very interesting feature. How do you enable it? You have to go to options and setting options, preview feature, select visual calculation and click on okay. I'm going to Showcase you that, and then there are certain examples have been given. There has been a separate blog on the visual level calculations also on the blog.powerbi.com, and it has been explained in detail along with all the visual level functions. The documentation of the visual level function is also available, and it has provided great details.
So let's read few part of this documentation to understand the visual level calculations better. Visual calculations is the DAX calculation that defines and executed directly on your visual. Visual calculation make it easier to create calculation that are previously hard to create, leading to simpler DAX and easier maintenance for better performance. Example of running sum has been given. You need to simply use running some sales amount. Visual calculation differ from other calculation index how visual calculation aren't stored in the model instead are stored on the visual, which means visual calculation can only refer to what's on the visual. Anything in the model must be added to the visual before visual calculation can refer it. Being visual calculation from being concerned with the complexity of filter context and model, visual calculation combines the Simplicity of the context from the calculated columns with the on demand calculation flexibility from measure. Compare to measure, visual calculation can operate on aggregated data instead of detailed level, often leading to the performance benefit when the calculation can be achieved either by new measure or visual calculation, later often leads to better performance. It means in case you have an option to create a major versus a visual calculation, you can opt for visual calculation for better performance because it is going to work on the aggregated data at the visual level, not at the detailed data. Since visual calculations are part of the visual, they can refer to the visual structure which leads to more flexibility.
There is one more article which you can refer to which tells the difference between custom column, power query, calculated column, measure, calculated table and visual calculations. Again, how to enable visual level calculation and some examples has been given. The first simple example was Sal amount minus total product cost. Then there are few things which has been explained here like you can hide the fields from the visual. These options have been given now to you when you open the visual level calculation at that time you can hide Fields. So let's read that out. In visual calculation edit mode, you can hide fields from the visual, like you can hide column and table in modeling view. For example, if you wanted to show The Profit visual calculation, you can hide sales amount and total profit cost from The View. Then there are using templates. So there are already existing template which you can use, which is running sum, moving average, percent of total, percent of R total, averages of CHS versus previous versus next versus first versus last. What are these functions? Running sum, moving average. Running sum you might have understood it is going to give you running totals or what you call as cumulative. Moving average calculates the average of the set of given values in a given window by dividing the sum of values by the size of the window. Percentage of parents calculates the percentage of value related to its parent uses collapse function. Percentage of grand total now become very easy. Calculate the percentage of value relative to its value using the collap Sol function. Averages of children you can use expand calculates the average value of set of values uses expand. Versus previous using previous means the preceding value. Next, subsequent value is next. First Value, First value in the window or visual. Last value, last value.
Now there is something known as AXIS. Many function have optional AXIS parameter which can only be used in visual calculation. X's influence how visual calculation traversing in the visual Matrix. AXIS parameter set to the first axis in the visual by default. It's by default set to the first axis for many visual. First axis is the row, which means the visual calculations is evaluated row by row in the visual Matrix from top to bottom. What are the different axes? Row calculates vertically across rows to perform top to bottom. Column calculate horizontally across column from right to left. Rows column calculate vertically across Row from top to bottom continuing column by left to right. And column row means calculate horizontally across columns from left to right continuing row by Row from top to bottom. Then many functions will contain reset. Many function have optional reset parameter which is available individual calculations only. Reset influence if and when the function reset its value to zero or switches to the different scope while traversing the visual Matrix. The reset parameter is set to none by default, which means the visual calculation is never restarted. Reset accepts there to be multiple levels on the access. So there to be multiple level on the access. Access means your bar visual can have like access like brand or category. So that is what we means by access. Similarly, when you are using year, month and quarter, they are your X's. You're displaying a visual there you have year, then you have quarter, then you have month, then you have days. So these are your X's. Something on which we are grouping the data, the categorical variable used in the visualization. If there is only one level on the axis, you can use Partition by. The following list describe only valid values of reset parameter: none, highest parent, lowest parent. Highest parent and lowest parent means the parent which is at highest. Example has been given like if you have year, month and quarter, highest parent is year and the lowest parent is quarter. It means the the lowest most X's value is not participating as a parent. It can also be used like values like one and two. So in this case because there are only two, so highest is one and lowest is two. So if you want to restart like when we are doing run running sum, now you want to transfer this running sum to let's say YTD, so you can use running sum highest parent. So it will reset at the ear level and you will get YTD.
AXIS and reset versus order by and Partition by. AXIS, reset, order by and Partition by are four functions that can be used in pair together to influence how the calculation is evaluated. They form two pairs that are often used together. So AXIS and reset on order by and Partition by. So with AXIS you can use reset, and order by you can use partition by. By and Partition by are the calculation you might have seen in the window function, OFFSET function, INDEX function, RANK function and ROW NUMBER function. Then this has been explained how to use this. Access and reset are only available function that can be used in visual level calculation and can only be used in visual level calculation as the reference to the visual structure. Order by and Partition by are the function that can be used in calculated column and measor and visual level calculation and can refer to the fields while they perform the same function they are different in the level of abstraction provided refering to the visual structure more flexible than explicit referencing Fields using order by and Partition by. See in case of exis and reset you may not be really explicit, and we will take this example when we do running sum that even if I change access it can still do the running sum. So let's say if I'm having a visual at the category and if I change it to Brand, the running sum will continue to do the calculation, and that's the benefit of visual level calculation. So let's say I have year, month, quarter and day, and I use previous function, so my expectation is that when I'm looking at the day level it should show me previous day, when I look at the month level it should show me previous month, when I look at the quarter level it should show me previous quarter, and when I look at the year level it should show me previous year. We have to check that at the visual level calculation, but if you use the order by then order by is very explicit. It is Day means it is J, even if you change your visual details it is still order by day. So order by is going to call explicit. When you need explicit you can use order by. Partition by when you don't need to be explicit you can use XIs and reset.
Available functions you can use many existing DAX function in visual level calculations. Since visual level calculation can work with confin of the visual Matrix, functions are rely on model relationship such as relationship, related and related table aren't available. These are the visual calculations available with you. Collapse, collapse all, expand, expand all, first, last, moving average, next, previous, range, running sum. Limitations: not all visual types are supported. The following visual types and visual properties have been tested and found not to work with visual level calculations or hidden Fields: tree map, map, shape map, Azure map, slicer. It means it's not going to work on slicer R visual, python visual, key influencer decomposition tree, Q&A, smart narrative, matrices, paginated report, arjs map, power app, power automate, small multiple. Visual calculation and hidden field can only be added and edited using powerbi desktop. While you can publish the report containing visual level calculation to powerbi ser, you can't edit visual level calculation or hidden field in power service. So that's not available on the service as of now. To edit it you can use it and publish it. Performance of this feature isn't representative of the end product as of now. You should not be too much bothered about the performance part of it. Reuse of visual level calculation using copying and paste or other mechanism isn't available. So you can't reuse them as of now. You can't filter on visual level calculation. Visual level calculation can't refer to itself on the same or different detail level. Personalization of visual calcul or hidden field isn't available, and there are many other which you can go through this article. I will be sharing the link of this article also into the description.
I have added a new page, visual calculation. On this page I'm going to add a table visual and start showcasing you visual calculations. To start with that I will go down and from item I'm going to drag brand and create a table visual. A table visual is ready and I've sorted it on the brand. Time to add a new visual calculation, and the option is available under the Home tab, new calculation. Let me click on that. Opens the window very similar to the focus mode window, and there you have a pain where you can give your visual level calculation, the FX pan or the formula pain. Now here the right now before I started the visual level calculation, visual level calculation is hidden. I can hide the measure if I need. I can't hide the AXIS or the group wise. So let me create the first visual calculation, nothing but running sum. The function which I'm going to use is running some, and I'm going to give net parameter. I'm going to leave everything else and not going to give any value for those. Now I can use the commit to commit the calculation or I can also press enter. I'm going to press enter. In this case the calculation is added to the visual, and as you can see the visual calculation which has been performed here it is adding up the previous value in each rows. All the previous values. If you look at here you can see all the rows is the sum of all the previous R. If you want to edit the calculation you can click on the arrow and you have option to edit calculation. So we have done a very simple calculation, running sum, and we have given net as an argument there. Let's go back to the report. Now what's the advantage? I was doing that using majes. Okay, maybe they are faster done on aggregated data, but is there any other advantage? To understand that let me do one thing. Let me go here on the brand and change it to category. Can you still see the running total working fine? This would not have been the case in case I would have created this calculation by any of the traditional methods. Now I do have tested this with field parameters, and as of now I was not able to add the field parameter to it, but the moment the field parameter is supported it would be really amazing because the moment I'm changing my field in the calculation it is still keep on working.
Now let's use another visual function, and the function which I want to use is collapse all. Again, new calculation, and I'll use the function collapse all, but that is total or gt grand total, cpol. What all cpol required? Expression and AXIS. The expression is net, and it is suggesting me to use the running sum also, but I just wanted the net, and how I want the direction? Rowwise down is the direction which I want, and let me use collaps all, and as you can see it has given me grand total. Now I can create two functions from here: percentage of grand total and percentage of running total. Again they are going to be the visual level calculations. So let me create couple more. So one is percent of total which is nothing but divide net by TT. Now I got the percentage of total, or I can add it and multiply it by 100. 100. I got percentage of total so easily. No calculation worries, just simply taking chy and use it on the measure. How simple it.
is now let's go ahead and do one more, which is percentage of running total. So again, click on the new calculation, and here we are going to use the percent of running total. And what I'm going to do for that is divide; so we are going to use divide, and we are using the regular DAX functions here. Divide is a regular DAX function by running some, which is a visual calculation; divide by another visual calculation, which is GT, completely based on visual calculations. Add it, calculation, multiply by 100 as of now.
So let's go back to the report and understand these. So first row, 22%; you're fine, because percentage of total in the first row is going to be the same. In the second row, the running total will add, and I'm not doing a running total of percentage of total; I'm simply have calculated it on running sum. I could have done it on the percentage of total also; that is another way to do it. And then another 14% getting added, another 23% getting added, and 100%. So such a easy to do the these calculations. Now we have already seen two functions, but there are many more, so we'll continue to look at those.
So let's do next calculation, and next calculation which I wanted to do is moving average. So I go and clicked on the new calculation, and let's call it as move AVG. And the function which is available with us is moving average. In the moving average, I can give an expression; expression is nothing but net. So expression window, do I want to include the current AIS row, column, blanks, and where you want to reset? So window is two; I only want to do for last two. I want to include the current as of now; I want to include the current, so I'll keep it. Otherwise, you can have the values like true and false, but let's start with only moving average. So what it is doing right now? So basically, the first value is the self; the second value is the sum of these two, which is 43 something, and just you can see it is divide by two. Now next would be the sum of these two, which is around 36, 3.6 million, divide by 2, and you can see it's 1.8 million. Next one is going to be some of this, which is going to be around 2.9 million, divide by 2, which is 1.47 million. And again this is going to be some around 2.4, 2.5, divide by 2, which is 2.22, 3. So in this manner, you can see we are getting moving average.
Let's go back. So we have got net, we have got running sum, we have got GT, percentage of total, moving average. And as you can see, we can go and change it, the XIs to something else, and this calculation is still holds true; that's the beauty of these calculation. Why, why don't we learn few more function? I would now like to experiment with few more calculation, and the calculation which I would like to now showcase is previous and next, which is going to give us the value of the previous row and the next row. So to begin that, Home tab, new calculations, back to the visual calculations. Let me call it previous. Function which I'm going to use is also previous; no previous month, no previous quarter, no previous here, only previous. And we have expression, steps, X's, blank and reset. And step means I can go beyond one. So I want to compare with previous month, that's fine. I want to compare previous to previous, then I can use steps and do it. I want to go further down, let's say 11 month or 12 month down the line, that also I can do by using these steps. It could be month, quarter, year, whatever you want to use based on the requirement, and it is visual level. So sometime if you have a disconnected data and you want to compare with the last available month, think about how much big calculation we have to do; this should resolve that out, because it's just looking at previous; it's just a visual row. And what previous of what? Net, anything else we want to give? Step, yes, definitely I want to give step one step. And because we have function like previous and next, it might not allow you the negative integer; it is only the positive integer which has been allowed here. It should would give me every time the previous row, and the first row will not have any previous row, because there is no previous for the first one. And as expected, the first one doesn't have a previous; rest all as a previous look up here. And based on these values, you are able to see the previous values here, going one down, trailing previous; well understood, very simple.
Let's do the next calcul, next; the function is very simple: next, net, comma, one step, done. And we got the next calculation, and this time it would be a one row ahead. And as you can see, the in this case the last row will not have it, because we are going one row ahead; we are looking into future values, and there is no value for the last row. In this manner, we are able to do previous and next calculation. Let's go back to the report and check this out. And as you can see, we able to see the next and previous calculation. And as usual, if I change the AIS to category, it's not going to make any difference; I will get previous and next of the categories.
Let's add couple more calculations; the calculations which we want to do right now is basically first and last. So before I do that, let me again change the AIS to BR; need a lot of values to look at the calculation; that's how you know only five category. First and last are just couple of steps away. Let's go ahead and try that out. So again, home tab, new calculation, very simple. First think about is how you're going to do it with the regular DAX index function; it's easy, but even that would require what is the order by, and you need to mention an explicit column for that. So function is first; let's look at the arguments: expression, exis, blank and reset. We are only going to give one argument as of now: net, and that should be sufficient. Let's check that out; calculation has been added, and as expected it is just giving me the first row value for all the rows. So I can now find out per percentage of first. Now let's calculate the last value. Again, click on new calculation from the Home tab; name is last, and the function we are also going to use is last, simple net, only one argument, but it can take expression, xes, blank and reset. We are only going to give one argument as of now: net, and as expected it is showing the last value. Let's go back to the table and look at it. Now we have quite a few calculations, as you can see we have first and last also, but we have more visual calculations, so we'll continue to explore those.
So the next function which we are going to check out is range, and it's little bit different function, and I'm going to tell you one different operation which you might not have seen till now in Power BI. Okay, so let's jump on to the new calculations from the Home tab, and I want to do a calculation which is range. Now range can give me moving average, but I want a moving sum, rolling sum, and that rolling sum I'm going to do using the range. So let me do rolling two, and little bit different function, so that's why I'm using calculate, and I'm going to use net here, but I'll tell you it might not work, so we'll come back to that later, and and I'm going to use function range. The range function, as you can see the arguments are step, include current; I want that yes, AIS which is rows, blanks, reset. The first argument, step is minus one, means one step only, last one step. Include current, I want yes, that is true. What is the next X's, which is nothing but rows, but when I give these arguments and I enter, it gives me error. And now to correct that, I'm going to edit this calculation, click down the arrow, edit calculation, and I'm going to do something which you don't do; I'm going to put sum on a major; it's a major, and usually we don't put some on a majure; we go ahead and use some X for that, but here I'm doing that, and immediately I get the correct calculation. It means you will be able to use some, average, etc. on your measure to get those rolling, the rolling averages, and your life has been made further Easy by this. Let's understand these calculation are they correct or not? First row is going to be the same; the second row is going to be around a million, the sum of these two; the third row is going to be the sum of these two, which is around 1.5 million. So let's look at the calculations; the rolling here is same; here it is the two which is last two rows, but this is 1 million, this is 1.5 million, and similarly it is going to be 1, 2 million; it's coming from here, these two on the top, and you can relate; just for your reference, let me put the arrow here. So now we have got rolling, and you have done little bit different kind of calculation, and let open up a all set of new calculations which you can do; important function range.
So let's go back to the table, and before we we move to the next set of calculation, we need a different kind of a visual, a visual where we at least need to have couple of access. So let's begin the Journey of few more special calculations, visual calculations, where we are going to get few more detailed or few more easy calculations just by using these visual calculations. Now to explore further the visual calculation, I have added a new page, because the set of visual calculation I want to explore now is going to require me at least to have two levels. So let me create a matrix visual for that, and in that I'm going to add state and city on the row, expand it, going to add a major net, and let's start the two calculation, expand and expand all. Again from the Home tab, new calculation; let's look at the calculation: expand, expand, and it require expression and XIs, and basically expand is going to work at the next level in the context. So the details would come from the next level, and we have to understand that. I'm going to have expand, expand all, and then I'm going to show you the differences, and then you will understand how these calculations are performed. So let's give here average; I'm going to use average function, and I'm using it on a major net. This is what we you can do in the visual level calculation, and the next thing which I compuls need is rows; XIs is rows. So expand, and you might not see the difference, but when you scroll down you will see an average happening at the state level and simply, and at the grand total level this number doesn't seems like an average of cities, because if you look at the number of the Cities, the number cannot average to 2, 100 K; this is actually the average of state, and that's what expand does; it is average of a level below. To explain this further, let's also bring in expand all, and expand all function also required to argument expression, where I will be doing average of a major; here again I'm doing an average of a major net, and the second argument is X's, which I'm going to use rows. And here if you see, you will see a little bit of difference in the averages; yes, it is the averages of City; it is the average from the leaf level; it is always calculating it from the leaf level, not from the next level or the level below. So let me go back to the report and try to explain you this; if you look at these calculations, look at how the averages is happening; you should be very happy to see these averages happening at the state level from the city level; no more those context plate defining what's below; I can easily go ahead and change it and add another levels or replace these levels, and they will continue to work. But what's the difference in the grand total here? To understand that, let me collapse it; I'll drill up one level, right? Calculation here remains same, but now you can understand looking at this data where I have a million here, I have a 400k here, which are pushing up my calculations towards the 232 as an average of the states. If you further go down, you do see some bigger values; I can sort on the net so that you understand these values little bit better. As you can see, quite a few big values are there. Here I changed sorting back to the state. So expand is doing it from the leaf level. To understand it further, let me add one more level; first of all I'm going to expand it, and I'm going to add one more level which is brand from the item. I have added brand from the item; immediately what you observe that this number is not changed in the expand, but the expand all number has changed. And why? Even even if you look at the city level calculations, those calculations are little bit different; they are not same as what we previously had; they were same when we didn't have the brand. If you go down, you will see these are nothing but the average coming from the Brand level, and even on the level above it will continue to be from the leaf level. So this expand all is doing the calculation at the leaf level; expand is doing at the next level. And what does that mean for you is basically when you see at the city level, it is average of Brands; when you see at the state level, it is average of cities; when you look at the grand total level, it is average of states. In this manner, these two calculation, expand and expand all, works. So this will help you to solve the common problem which we wanted to do: average of sum or sum of averages; very common problem and a very simple solution in visual calculation.
Now we are going to look at the two function which is basically cpse and CPS. I already shown you cpse all ones, but the time has come that we again look those two things together. I'll go to the new calculation, and I'll first do here collapse, and collapse requires expression, x's and N; it's basically give going to give you the grand total or the parents total; is basically going to collapse it. Here I can use net, comma, rows, and as you can see here is collapse is getting its ground total, but the cities are getting the total of the state. So to understand that, look at the state total; this is my state total; the cities are getting the state total, and if you further go down, brands are going to take the city total, collapsing from the parent to child. So I'm getting the parents calculation at the child level; so that is collapse. But if I do collapse all, which is going to bring a grand total for me, so let me add a new calculation, that is colol, or I can call it as GT, but let me call GT1; I can already calculated GT not in this visual; I calculated another visual, so I can have the same name, but just use now call appol, and the call appol is going to do it all at the final parent level. I can use net here, and I can use rows, and this is nothing but grand total. So now you can easily calculate percentage of parent, percentage of grand total; again use them back into new calculation, or you can edit the same calculation to get it percentage of total or percentage of grand total. CPSE and CPS help, help you to get the parent values. Now go back to the reports and let's understand these things. So here we have already opened Arizona, and we have open one of the city of Arizona and their Branch under it. If you see here, this is the total of the city, and this is given at the Brand level. Now when the Arizona has been opened, Arizona has a total of 471; look at the city totals; all the cities are getting the Arizona total. When you go to the states like Arizona, you get the total, the grand total which is above one level; it collapse is collapsing one level at a time; collapse all is collapse all the levels. As you can see, we are getting the ground total here for all the rows, irrespective of whatever level we are at. We already have a quick glance at these calculation, but we do would like to explore the reset functionality. I would like to see how would it work in case I want to create a running total which is not going across the leap level, but can it reset itself to ear level? So let me add another page, and here I'm going to create a line Visual, and in this line visual I'm going to bring in from the date table; here I'm also going to bring in quarter, and I would also like to bring in month, and I would like to bring in a major net. So I'm all set already with my visual; this is my visual, and how it's showcasing the values for last couple of years. And let me do a sort on the AIS, so I have my visual ready, and here I want to have a running calculation. Let's first of all add a visual level calculation from the Home tab, and the new calculation which I'm going to add using the Home tab, new calculation, is running some net, and let's call it RT. And as you can see, the moment I take an RT, RT is going up. And if I go back to the report, you can see it's continuously increasing. I don't want to add another calculation; I just want to go ahead and modify this, so I click on this arrow and use edit calculation. And now I would like to look at the other parameters of RT. So AIS is definitely row only, blanks, and I want to reset; I want to reset at what? I want to reset at the highest parent, so highest parent is here, and I want to reset there; let me try that out. And what do you see? Immediately you see there is a fall happening in the month of January. Let's go back to the report and understand that. As you can see here, there is a reset happening, and this means now I'm getting YTD; no more I'm getting running total. RT, can I get it further down to the T number two, which is quarter? Let's see. As you can see now, it is giving me QTD, not YTD; every quarter there is a reset. So look at the January, look at the April, look at the July, look at the October. Let's add more complication; let's add date; what happens now? The reset would still happen at the level two; the level two is still quarter, so the reset is happening quarterly still. And we do it, and remember this quarter is in the middle, and that's why knowingly I have added here two, and I added one more level to Showcase you that the reset is is not happening month level. So there are more levels available here, and it has taken care; this is the second level, so 1, 2, and 3; is it three or is it one? Let's go back, edit calculation, move the level to three, and let's understand this calculation once more. And now you can see the reset is happening at the month level; the highest level is one, the second highest is two, then three, four, and keep on going. We are not including the current level; the current level is not part of the parent; your parent as a year is one, quarter is two, and month is three, and we have given three as of now; you are seeing MTD in this particular Trend chart. Now you understand how easy these calculations are, and how easily we can use visual level calculations to create those complicated calculations in an easy manner. We are just working at the visual level; the visual row is the row; the visual level is the level, and that makes our life easy; it's just like Excel; we are doing it; those who likes the Excel calculation very much and very find it easy to do those kind of calculation, this is one step near to that.
I have shown you quite a few visual calculations in detail, but there is a quicker way to do some of these calculations using templates. So where is those templates available? For that, let me add a new page, and quickly add a table visual with item, brand and net. Visual is ready, and now let me add new calculation from the Home tab, new calculation, which is a visual calculation. When you come to the visual calculation, look at this FX icon; when you click on this FX icon, you get the options for some templates. So without doing much of the effort, you can simply
Get some of the calculation. The only thing which you have to do is just click on any of these calculations. Let's say percentage of grand total and go ahead and add the required field. Now I'm going to replace it with net, the field with the net, another field also with the net, and X is with rows. So we immediately get percentage of total.
Same way I can click on the FX icon again and use versus first. Again, I need to replace the field where I can replace it by one of my majors which is Nat, which is also present in the same visual, and I'm getting percentage diff with first. Same way you can utilize running sum, moving average, percentage of parent, percentage of grand total, average of children's, versus previous, versus next, versus first, and versus last. So not only you can create these calculations by using the functions, but you can also use some of these templates. So go ahead and try those out.
Visual calculations is not limited to the set of new functions which has came along with the visual calculation feature. Some of the existing functions can also be used in the visual calculation. While we have lot of functions which we can use, we will be focusing on few functions which are released some time back. These functions are index, offset, Rank, and row number. These functions have been released during December 2022 and April 2023. Now while all these functions may not work in visual calculations, we will try to see how can we use them in visual calculation and what all functions are going to work there.
So in the upcoming videos we are going to explore visual calculations with these additional functions which are very similar to SQL Windows function, which are index, offset, rank, and row number. Those provide us order by and Partition by. I would like to go ahead and see whether offset, index, window, Rank, and row number can work with Dynamic rows, means XESS. So we need to check can these functions work in visual calculation and if they work, can they work in the visual when we change AIS or row of the visual? Will they continue to work like the other visual calculations we have learned in the past like previous, next, running sum, moving average, etc.?
And why I'm thinking these functions can work in visual calculation is the part of the documentation which I'm going to showcase you. I want to perform them at visual level without using explicit table or relation. By doing so we will be able to create more flexible calculation which can still work even if we change the AIS. So friend, with that objective I would like to first of all show you the two statements which were part of the documentation which motivates me to experiment this. So one of the statement which we have looked last time is this: exis and reset and order by and Partition by and they are pairs. Now the second pair is the one which is used by the five functions which we plan to discuss, and usually these functions need explicit columns. In spite of those explicit column, can we make them little more Dynamic? The second thing is when it talk about available function, it do say you can use many existing DAX function in visual calculations. Let's go ahead and try the existing DAX function and see whether they can fit in into the visual calculation the way we wanted.
The next visual calculation which we would like to explore is using the index function. Now I'll leave this page here and we'll further go to another page and there again I'm going to create the same visual. What we have started with is brand and net and the function this time I would like to use is the index function. So let me click on the visual and the new calculation and I'm going to call this function as index. Calculate net index. What does index function require? Position, relation, order by, blanks, Partition by, match by, and reset. So what we are going to do is index is first index. I want the first one based on the relation which is nothing but rows. What's the next thing I require is order by and here I'm going to use an order by, explicit order by, order by at descending. And as you can see I got the first value. I can go ahead and modify this calculation to have the second value also. So second value, as you can see it is the second value. I can go ahead and use it as a third value also. So this is the third topper. Same way I can use minus here which is not possible if you would have used the first and second. So if you would have used the first function you cannot get all these, but you can get with the offset and I can make it minus 3 which is actually going to give me the bottom third. Same way I can have another calculation, index one, where I can use calculate net index and here I can use position as one again and rows and I can leave the order by to take the default order by and as you can see it has taken brand one the first position because that's the default X's order by.
Let me go back to the visualization and as you might have expected if I change it to category it still continue to work. So this is my third topper by net and this is also the categorical first Total. Both are same here, that's why the number is coming same, but they are doing two different calculations. Same way I can add both of them together, brand and category, and calculations will still work. So one of them would be on the bottom third and one of them would be based on the top.
Next visual calculation which we wanted to explore is using the offset function. So to start journey I will bring in brand from the item dimension and I'll also add net mejor. I would like to do visual calculations. So how do we do that? From the Home tab, new calculations, click on new calculation and the function which I plan to use is offset. What offset used to do for us? We can go to the previous position or the next position by providing an offset, just like we have got previous here. Now I'm going to use calculate net which is required with the offset function. You can opt for other options also. Now I use the function offset. What does offset function require? It requires Delta, relation, order by, blanks, Partition by, match and reset. Let's go ahead and try these out. Minus 1 is the Delta, then relation, and here I'm doing the first change. So instead of using all selected item brand or all item brand I'm using row and remember we are doing a visual calculation, so getting data outside the visual might not be possible for us. The next thing is order by and because order by might require a explicit column I'm as of now leaving that as is and because it's going to pick up the default order by or the first AIS I'm expecting it to sort on brand and as as you can see we are getting values which are one row behind the same as previous, but what the difference is going to make in our life if I use rows instead of explicit table call or explicit relation call in the offset function. Let me go ahead and change this brand to category and you can see the calculation is still working. It is still giving me the previous row value. It means I am no more dependent on what is there on my Axis. So I got rid of that. It makes offset function much more powerful than what we have used it previously.
Now let me change it back to brand and I would now like to go back and can I run this offset on net? I will add another new calculation here and I'm going to call it offset one. Again calculate net offset minus one rows in the relation as we have given previously also and this time I'm going to use order by and order by is still looking for a explicit column here or can we give one and two? We have to experiment. So here I'm going to give explicit name net and if you remember the there has been a change done after this function has been released that in the order by we can use major which is not part of relation. Net is not part of the relation but we can still use it and how do we want to use it? Descending sort. So I have pressed enter but after adding additional parenthesis and it has worked. Now to understand this we need to change the Sorting of the visual. As I've sorted it on net you can see that now it is is trailed by net. So I'm getting previous row based on net sorting. It is not sorted on brand or the default access. Can you do that using previous? Try that out and do let me know in the comments. Can you do the same thing using previous function? If not, offset is your choice.
Let's go back to the visual and understand these calculations a little bit. So right now the Sorting is on net, so you can see it Trail by a row, but this function first offs set how it is working? It is actually still working but it is trailed by the order of brand. If you see brand one and after that if you go to the brand 10 you will see that value because the Sorting order is like this: R 10, 11. They're still working but they're working based on their own order. The interesting thing we are able to use offset now. I already experiment with the Partition by which did not work for me, but let me showcase you that can we use the last reset option. So I will use calculate net offset minus one, one relation is rows, order by I will leave blanks, I will leave Partition by, I will leave match, I will leave and reset. Can I give highest parent here? I'm giving highest parent here. No order by has been used doesn't seems to have make any difference, but we need more than one parent for such a reset, isn't it? So let's bring bring in more than one column here. So let's bring in category also here and we would like to see the calculation of this offset versus this offset. Is it making any difference? So if you see here it is already sorted on the brand which is the highest parent and pose that this is 1, 4. So if you look at the first calculation the offset and you look look at the second calculation of the offset it same sounds like doing the same job, isn't it? Now let's add one more. Do you see a change here? To do that let's first of all bring in these two things together. So I have the offset and the calculation together and I don't see any difference. Let me convert it into a matrix and now you can see the moment I have a visual like Matrix visual where the concept of the parent Works. Remember the concept of the parent has to work and the moment I am on a matrix visual where we have this concept of a parent because remember all three of them were on the same kind of axis in the table Visual and the concept of hery is not too much valid in case of table visual. It is more valid in case of Matrix visual. Now here you will start seeing a difference. So one of the difference which you are seeing here this is the first value. If you remember this is my first value to this calculation. This also get carried forward to the first calculation. We are still in the brand one. When I go to the brand 10 this is my boundary of the brand 10 and as you can see inside the brand 10 it is not getting the value for for the first category and to make it easier to understand let me first remove the subtotals. So let me hide the subtotals. Now as I've hidden the subtotals what do you see between offset and the calculation? What is the difference between the two? So to observe that look at the brand 10 only. Inside the brand 10, inside the brand 10 what you are seeing here is here I'm getting both the values but only I'm getting here one because the reset at the one has applied. So it means if you're not able to use Partition by you can still use reset. So you have a reset option which can work in such scenarios. So now we have understood that how we can use reset in offset function instead of Partition by and if you remember we do have the flexibility of using numbers here 1, 2 and 3 depending on what parent we wanted to have reset. We can also try to experiment with that but I'm not going to do that experiment as of now. I'll leave it for you to go ahead and try that out.
The next visual calculation we wanted to explore is using the rank function. And now I would like to use the next function which is nothing but rank. New calculation, rank function. I'm going to use is rank, not rank X. This is the new function, function came in April 2023. What I want to use is ties which is nothing but dense and what does dense means? Dense means if you are using a rank and the rank getting duplicated like 1, 1, 1, 1 then the next rank would still be two. It is not going to skip the rank. So we'll get continuous rank. What is relation? Rows. Do I want to do I? Order by? Yes, I would like my ranks based on net, but you know that you can do it without that also and the ranks are based on the net as you can see the moment I sorted it you are getting your correct ranks and if you want to do the rank based on the axis you can add another visual calculation, click here and in the visual calculation give it rank one, rank function, dance, Rose, leave everything else. It is based on the AIS as you can see here. Let's go back to the visualization. What's the beauty? As you know we can change it, we can add additional one till the rank should work based on the net. We have not explicitly called it for category. You explicitly called it for net, so that is what it is going to continue to work for the net when we do the visual calculation. Now the visual calculations are also limited to visual, so whatever data is not present in the visual it is not going to do a ranking for that. If you are looking for that all kind of a scenario you might not be able to replicate that here. So you are able to use now rank also in the visual level calculation with the visual level arguments like row. Can we do a reset here of the rank and for that let me duplicate this page after renaming here. Let me change it to Matrix Visual and let me add brand, disabl row sub totals and expand it as of now. As you can see the ranks have changed their order a little bit because the thing is the moment I sorted it on net the net is actually sorted not for the brand and category. It is first sorted on the top brand and then the second top brand and then inside that for the category and that is why you see this rank is not working in a particular descending order but on a table visual it is going to work as expected and but we would like to add a new calculation here which is nothing but rank three and here I would like to use rank, ties is T, relation is row, order by is net, order by is net descending. I leave blanks, I leave Partition by, I leave match by and I want reset, reset as right now I'll use lest parent but in this case lowest parent and highest parent are same so let's try that out. So it is saying reset parameter cannot be used with the combination of order by and Partition by because I've used order by so it is not allowing me to use the reset. So let's go ahead and edit this calculation and remove the order by. Does it work? Yes, it does work as we have learned only the combinations can work, exis and reset, order by and Partition by. Let's go back to the visual and as you can see the we are able to partition it when we are using the default access. You can now observe that the categories are ranked properly inside each brand. So there is a reset happening for each brand and categories are ranked inside that. So we know that the combination is there and that combination is applied on this visual, the row and AIS and order by and Partition by, but we don't never want it to to call it explicit so but still it is very good that we are able to change it for category and brand whenever the access is changing it's still it is working so that kind of rank is working for us.
The next visual calculation which we would like to explore is using the row number function. Now next thing which you want to experiment with is the row number. With the row number I would like to create a table Visual and this time I'm going to bring in something which is having data at much granular level. So I'm going to bring in order number number as non-summarized and I'm going to bring in sum of quantity. I no don't have any measure here. I would like to sort it on sum of quantity and now I would like to build a calculation which is row number. I want to give the unique row number here in this visual. To do that I will start a new visual calculation and I'll call it row num one and I'm going to use the function row number and in this row number function I'm going to use the relation which is row. Next thing is order by and in this order by I'm going to use the something which is we have in this visual, sum of quantity. See I'm not created a measure here. I'm going to use sum of quantity in this visual calculation which is only present as a implicit measor not an explicit mejor defined by me. With the help of that implicit one I'm using it and as you can see on on the first one you are able to see the row numbers getting from 1, 2, 3, 4. Let's go back to the report and you can see that we do have the row numbers here 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. Can we create a multiple combination and can it still work out? So let's go ahead and add City ID to the visualization. Yes it is working but order number is still giving the uniqueness and anyway we will we'll always get a unique combination. So let me add an item ID also here, Item ID and City ID still we are getting the numbers and let me change this combination now. Now it is based on the combination of item ID and City ID, no more the combination is based on the unique order number. So based on the unique combinations also it is working and we have not changed anything in our function, the row number function like we have not done any explicit call here. Without any explicit call of the relation it is still working. So that is what the advantage of visual calculation.
The next visual calculation which I want to try out is on the window function and it did not work out for me. So let me showcase you what I tried out and what did not work for me, but you can go ahead and try and experiment and let me know in case you are able to make it work. So I went ahead and added brand along with net. Now I will go ahead and add the new visual calculation and this time I would like to use window function. I've done few experiment, none of them has given me the desired success. So calculate net window. As you know window require first to argument the window position, something which we have experimented with the range. So if the window doesn't work, range is there with us to do all these calculation. We can use that. So from what from the minus one relative position to zero relative position and the next thing which I wanted to use is relation itself which I was trying to give rows and I don't want to give any order by right now and try to experiment with the window function and it did not work as I was expecting it to work because it is requiring a unique context which I'm not able to Pro here. I went ahead and I said okay let me edit the calculation. Let me see if order by can help us. I used order by net DEC and I again committed this calculation and it did not work out for me. So seems like for the window function it is not working for me. The other thing which I can do is absolute to Absolute. This is something which can work for us, zero absolute to minus 1 Absolute. Let's try from 1 absolute to minus one absolute and let's see does it
Work? No, it didn't. So, it seems like we will not be able to use window function as of now in the visual level calculation using the rows as X's. I've even tried the experiment by giving here all selected brand and item brand so that calculation also doesn't work for me. But this is an experiment for you. Can you make the window function work in the visual level calculations? Go ahead and try that out. But now we know that we have made quite a few functions working for the visual calculation that include offset, index, and rank. Now, number the four functions out of the five functions which are very similar to SQL window function which provides us order by and Partition by. We are able to use in visual level calculations. One of the most common functions which you use very frequently is rank. Now, can we use RANKX in visual calculation? Because if we can use RANKX in the visual calculation, it will provide a lot of flexibility when we are going to calculate the rank. So, so I'm going to go ahead and try out the RANKX function in the visual calculation and explore how can it help us doing visual calculation and how our ranks will become more dynamic when we use RANKX in the visual calculation.
So, I'm on the Power BI file, and here what I'm going to do is I'm going to add a new page. And inside this new page, I'm going to add brand and net. Make it a little bigger and convert it into a table visual also. Now here, I want to add a rank. So, how do we use, use a RANKX function and do it? But this time, I don't want to use the RANKX function as a measure; I want to use it as a visual calculation. Let me click on the visual; that's how the visual calculations are enabled. Go to the Home tab, and there I'm going to click on the calculation. New calculation is the option to do that. I'll click on the new calculation. Visual calculations have been opened. Now here, I'm going to write down a new calculation which is Rank, and rank, I'm going to use the RANKX function. RANKX, if you remember, in the RANKX, the first thing which, which we need to give is the table, and that is where I'm going to use rows. Expression is basically our column where we are going to, third item usually we keep empty. Fourth is order, which is by default descending, and dies is the fifth one, which is by default. Let me start giving that. So here, I'm going to use rows. So I'm not going to use any like all selected table column. I'm the second one is my net measure which I wanted to use, and third one is the values column which I'm going to leave empty. By default it is descending, but I can give descending here, and the dense because skip is default one, dense here. As my visual is already sorted on net, you can see it is showing you the rank one for the maximum amount of net what we have. Now, the question which you may ask is how it's making a difference. You would have done this RANKX function all selected; it would have behaved in the same manner, isn't it? So let's do one thing. Let's try to see if you already have a rank function. I do have a rank net which is also on all selected item net descending dense, very similar measure also I have. So I have a visual calculation; I have a measure, and you can see this is visual calculation and this. So while I have both, and both are giving the same, but let's we go ahead, go to brand and click on this arrow, and I change it to category. The moment I change it to category, the thing which you will notice here, basically this rank got adjusted, but this is the one which is not getting adjusted. Now, why it is not getting adjusted? Because it is talking about item brand. Brand is not in the context, and that is where it all brand is not get listed. But here we are talking about rows, so here it is changed from Brand to category, and now it is able to adjust. The second case which we can test out is basically let's convert this into a matrix. Now I have category, and inside that let bring in brand. Inside the category I have brand. I added the brand, and I'm going to expand this Matrix visual. Let's see what do you see a difference here. Now here what is happening here is this brand is 1 to n, so each brand is getting rank within the category, so there's a partitioning which is happening. But here when you see these things, this is not getting same way partitioned; there are different ranks. And if you see there is a one, two here, and then there's a three here. So remember category 4, Brand 2 is at number three, and category 2, Brand 8 and Brand 9. Now to understand this, let me convert this back into a table visual. When I convert it into table visual and I sort it on net, which is right now the sorting, you can see that it is actually sorting it on the combination. So in the second level, the Brand level, when I is seeing in the Matrix visual, while the rank is partitioning it by category, this one is not getting it partitioned. Now we, we have like, you know, rules, how do we partition and not partition in different functions like we have rank function where we can give Partition by, and there we can deal with. But in this scenario, especially with the RANKX function, as you can see now when I'm adding two, it is taking both of them as rows, and you know, it is giving the rank based on that. Now this is one of the challenges which you had in the past like, because if I keep on adding how many ranks I'm going to create, and this is where you know a visual calculations helps, helps us a lot that my rank is independent of what I have in the calculation. I simply using row, and it can change based on the visual, so I don't have to specify a particular column. I get that independence that I can change my column inside my visual, or I can change my group buys inside my visual, and my rank can adjust to that. While in major calculation that's not possible because they are tied to a particular column of field, and they're going to behave in a manner they should behave when this column is tightly attached to that particular measure. So this is the real benefit, and now you would have understood that you know what benefit each one of them has. Now, sometime I would like to have a measure because I have that kind of a scenario which is basically the rank should get partitioned as soon as I add something else, and that is what the case is. And sometime, you know, I have to explain that again and again. In many videos I've done that, the moment you add additional stuff, the rank is inside that additional column which is not participating in the rank or get partitioned by that other column because we are limited by what column we have put it into the RANKX function in a measure. But that's not the case with the visual calculation. Visual calculation has been announced in October 2024. So let's have a look at what all enhancements has been done into the visual calculations in October 2024. There are few enhancements which has been rolled out on the visual calculation, and one of them is using the field parameters along with visual calculations which we are going to explore today. So let's jump on the release note, look at what are the new features which has been given for visual calculations, and we will explore them onto the Power BI desktop.
I'm here on the Power BI October 2024 feature summary, and in this feature summary, one of the features which you will find under the content reporting is visual calculation update preview. Once we click on that, we go down; it talks about combo charts are now supported in the ual visual calculation. Now the combo chart are supported, so you can now use visual calculation in combo chart such as line and cluster column chart, just you could in the other chart types. Here is an example of visual calculation reporting moving average for 3Qs. So one example has been given for combo visual where we can see the moving average has been added on the line. Three-quarters moving average has been used on the line of combo visual line clustered column chart. And the another feature which we are looking forward mainly for today is field parameters are now supported. This month we have enabled the visual calculation with field parameters. You can add visual calculation to the visual containing field parameter or vice versa. Field parameters can be used to quickly switch around what's shown in the visual. For example, you can create field parameter to enable your users to decide which attribute dimension to show. For example, field parameter called Product attribute can be used to determine the percentage of grand total. You have the percentage of grand total which is using rows, and you can switch the AIS using the field parameter, and it will continue to work. Another update is faster ways to add templated visual calculation. You can now add templated visual calculation with fewer clicks by clicking on the button as part of new visual calculation. Previously to get the visual template, you have to go to the visual calculation, and there you have the option to choose the template from the calculation. Now the template option is available directly under the new visual calculation under the Home tab, and you can use it from there. You can also start new calculation without template using custom option. So these are some of the updates. Let me jump onto a Power BI file and showcase you these updates.
So I'm here on the Power BI file. This is the file where I have already done some visual calculations in the past also. I'm using the dark mode which is recently released, so you can see that my UIs of the Power BI are in the dark mode. First of all, I'm going to add a new page into this UI, and I will take you through the features one by one. First of all, let me add a table visual. So I'm going to add a table visual, and inside the table visual let me bring in brand and the major net. I have a visual brand with the net, and let's say I want to add a visual calculation. How do we add a visual calculation? I to go to the Home tab, and inside the Home tab I have new visual calculation, and as you can see the new feature which is already been discussed that you have the access to the template quickly. You don't have to go to the calculation and choose one of them. So let's choose percentage of grand total as one of the calculations. So using that template, we have come here directly. You can see we have percentage of grand total, and I can use net as my major. Collapse all function is going to give me the grand total net again, and Xes is rows that remains dynamic. Now I got my percentage of total. Now you are not seeing percentage, and I'll tell you the new feature which will enable you to see it in the percentage format also that came very recently, few months back. Let's go back. Now we would like to format this percentage of total. Click on this, go to the format. I opened the format. Now inside the format, go to properties, and inside the properties data format, choose the percentage of grand total. The data type is decimal; the format is percentage. Once you choose the percentage format in the decimal data type, you will be able to see in the percentage format. We have saw one more feature, and that the feature is it is supported on combo visual. So let's make this chart as line cluster, and let's try to move this percentage of grand total from the column of Y AIS. Line YIS visual is now showing percentage of total along with the net. What we can do now is we can sort this visual on brand and observe it again. Let's sort this on brand; we can observe the visual again. Now we can see net as well as percentage of grand total together. Now to make it little more interesting where you can differentiate what line is doing, this is what bar is doing. Let's convert this line into percentage of running total line. So let's edit this calculation, and how do we get running total? So we have another template for running total, but we do have a function running sum on the top. I'll take running sum X is as rows. So let's divide running Su by total, and let me go back the report and let me sort this on the brand ascending. And as you can see, this is now showing me running percentage of total. We are able to explore the second feature also. Let me convert this visual into table. So we have a calculation net; we have a percentage of grand total which is actually not percentage of grand total which is percentage of running total, and I would also like to add one more function, offset function or index function. I'll add one more calculation here; that calculation is last. So what is there in the last? So I can use offset function calculate; we have previous here, but I would like to use offset here. Net comma offset minus one, relation is rows, order by is net D. Actually I wanted to have specific order by, and that is why I used this offset function for last row. When I go back to the report, now this function for that I need the sorting on the net. If you see, if I do the sorting on the net, it's giving me the last two. Let's do one thing; let's duplicate this visual. CU, they both need different sorting, and now from the first visual I can remove the last row. From the second visual I can remove percent of running total. Sort first visual on brand and second visual on net. The reason for this change is because one of my visual calculation is working on the axis; another one is working on the measure sorting. Now what I would like to do is I would like to make both these visuals dynamic by using field parameters. So I would like to change the a/row and see that the calculation is still holds true for that. I would now like to create field parameter that is going to change my categorical variable or access. To do that, I will we go to modeling, new parameters, Fields. I'm going to create access; let me call it as access one, and here I'm going to select from item table brand, category, subcategory. From geography table I'll select state and city. I will leave this option add slicer to this page as is; I would like it to add, and then I can now click on create to create my field parameter. Field parameter will add a table with a special syntax which enables us to use the field parameters. This I have explained in the past also. Now we got the field parameter; we also got a slicer; we would like to utilize it. Let me first of all adjust it little bit. Now we have adjusted our visual, but our visual are not following any access, isn't it? Let's go ahead and change the visuals to use access. I go to the first visual, and I will go to access, drag XIs one and remove brand. I will do the same in the second visual. I'll click on the second visual, drag access and remove brand. Visual is sorted on AIS or categorical variable, and second one is sorted on the measure. Now let's change the access. Both the visuals should change. If I change the access one, I change it to category. As you can observe in the first visual, we are still getting the correct percentage of running total; it is still rolling up to the 100%. So you can observe in the second visual that we are still getting the correct prior with the help of field parameters. XIs has changed, or the row has changed, or the categorical variable has changed, but still we are able to see the last row value based on visual calculation which we don't have to change. Let's look at State. When we look at the state calculation again, you can see my percentage of running total is still working as well as you can observe that the prior calculations are still working fine; are still getting the previous row value in spite of change in the categorical variable/xs. Look at how simple and quick calculation we have done, and those quick calculations have not only worked with what categorical variables or what axis or what row we had in that visual, even when we changed it, it continue to work, and the last item before we conclude for today, let's have more than one, and does it continue to work? As you can see calculations are still working, and this is the beauty of visual calculation, and we can say visual calculations are better together with calculation group. So why don't you go ahead and try this out.
So now let's dig deep into the conditional formatting details. For doing that, what I've done is I've already created few set of visuals where we are going to experiment with. I'll also tell you where you will not be able to do the conditional formatting. So what do I mean by conditional formatting? So in every visual, when you go to the visual format, you have a color option. Now the color option under the bars, in case of bar visual, in case of column visual column, in case of Matrix and table visual, you will have the colors under same cell element. Various conditional formatting options are available. Table visual and the Matrix visual have a lot of options; they have on background, font, then they have data bars, icons, web URL, a lot of options. Now let's start with first of all the conditional formatting on a table visual. So conditional formatting has few limitations like in case of the Matrix visual, when you click on the Matrix visual and you want to do conditional formatting, you go to series; you will not see anything for the rows and the columns. Me, you can't do conditional formatting on R feeds and column feeds. On table visual, on contrary, you will be able to do almost on everything on the visuals like bar and Etc. You cannot do it if you have more than one major or if you have a legend. In these kind of visual, the, the sign is basically you see this FX button, and the moment you stop seeing this FX button, you do any action and you don't see this FX button, it means you will not be able to do the conditional formatting. So let's say if I drag category on the legend, you will no more see that. Okay, so it means the option is not available. You can see the color color for each series, but you can't do a conditional form. Similarly, when you use more than one major also, you will not get that option. You don't have the options for the conditional formatting; the FX is not there. In case you have a pie visual, me create one; you don't have conditional formatting options. You go to the slice; you don't have the option. Same way if you create a line visual, you again don't have a conditional formatting option under the line. So there is no option under the color, and at few places we will be able to get this even without having those options. At other places, we'll not be able to get it. So let's start with the conditional formatting, and first of all I'll, I'll quickly explain you the two conditional formattings options to you on the table visual. So in the table visual, I can do conditional formatting on any of these, but let me bring in a major. So margin major, I want to do background conditional formatting of form or data bar or icon; all are available here. I can go to the background conditional formatting; I click it; you immediately start seeing because when you click on FX, you realize by default the gradient conditional formatting already been picked up. In the gradient conditional formatting, you can use a major, and it is not necessary that when I use margin, I need to use margin measure. I can use any other measure, then I can also I specify when what should I do for empty values; don't summarize, treat it as zero or specific color. So this option is available in the gradient condition form. I can use the minimum maximum color gradient, and I can choose it. Now if it is a reverse like discount, it should be reverse; the minimum value is good. Actually I can have a middle color if I want, and once I use the middle color, uh, it will give me a try color gradient, and I can use any color in that manner. I can actually build in my gradient conditional formatting. It can apply to values and total and total only. Right now I'm keeping it only as values, and I'll apply gradient conditional format. The other options here are rule base and value base which we will explore in a while. You are now getting gradient conditional.
Formatting the same option would be available in all the visuals. Now, here in the table visual, we have more options; like we have an option for background, we have an option for uh font color, data bars, etc. But this font and background color—so this option would be available in the color option of most of the visuals. Now, table visual is the only visual where you can actually create a row conditional formatting. Because if you can repeat this, I can go ahead and, you know, I chose my margin percentage; I can go and repeat this on discount percentage, repeat this on net, repeat this on brand. So I can actually create a complete row conditional for same conditions. I have to repeat the same logic; I have to repeat, and it is not necessary. Then when I'm doing conditional formatting on brand, it is not necessary when I do conditional formatting on discount percentage that I have to use discount percentage. I can still go ahead and use margin percentage, and I can still use the same logic. So I will have similar kinds of colors, and if you repeat this, you will get a color draw.
Then comes the font formatting. Let's complete the different kind of formatting, and then we will go to the rules and the field value. In the font condition formatting, you actually color the font. So let me color the font this time based on the rule values—only value gr total. I want to Value. Usually what happens, value rule based conditional formatting. Let me apply it on based on the—I'm applying it on net, but I will apply based on the margin percentage. I should be knowing what are what is the values I have, because values will change based on the group wise. Now, even though I'm doing it on percentage column, and this is something you should remember that even though I'm going to do it on percentage kind of a column, it needs to be done on number. Everything should be number, and it it should be between 0 and 1. So these are basically .13, .13, .14. So I have 10%, 11%, 12%, 13%, 14%; that's the max range I have. So what I can do, I can say, okay, it needs to be red when it is between 0 to 12. Okay, everything should be number now, because it is strictly less than. Here what I can do is I can go ahead and say greater than and equal to again point .12, and then not percentage; I want a number. And from there strictly less than .14, percentage 14 percentage, and this color I can keep it as orange. So again, everything is number, not percentage.
Now let's add one more rule. Again, we have given the last condition, which is basically till 14%, 12% to 14%, strictly less than 14. So now it could be greater than 14%, .14, and it could go till one, or it can whatever number you wanted to give. The best way is to give it at one, and here like if you have negative values, the first value you can go ahead and change to let's say minus 1 or -100, whatever you want; minus one could also do the job. So what are my conditions now? My condition is from negative to positive 12% number; everything it's going to be red. From 12 to 14%, it's going to be yellow, and from 14%—now let's change this from 14% to anything which is till 100%—should be green. So we use green color. So now this is the color what we want. Let's click on okay and see how does it apply. And as you can see, it has applied the color. Now the first color is not visible; let's make it little bit bold so that we can see it. So we can make the values bold if we want, like this, to look at the color. So these are the conditions now we have applied, and now based on that condition the colors are coming. I'm reverting back the bold right as of now. So this is rule based conditional formatting. The rule which you have to remember: percentage means allocation based, and number means you have the exact value which you are planned to use. Even if your column is a percentage column, you need to use number because you are giving a range; you are giving the exact number range, and for that you need to use numbers, not percentage. So we are done with the font conditional formatting.
Now what is this data bar? So basically what happens when you click on the data bar—I'll keep it on net—it will add a bar. The filling of the bar—if you go to the FX, the option you have is the lowest value, highest value which you can give; you can get the values, or by default it will decide by itself. You have for positive bar and negative bar, and X is color. Now there's no conditional formatting further on it. You can choose left to right or right to left; also you can choose—it will start from the other direction also. There's one option: if you only want to show the bar, you don't want to show the number, you can choose that. In that case you will only see the bar. So these kind of stuff you can do. Now comes the icon conditional formatting. In case of icon conditional formatting, you can click on FX, and there are always a rule again. When you are using the percentage base, please remember this is allocation—so allocation of net value from 0 to 30, 33 to 67%, and 67 to 100%. And that is why I was warning you that we are not going to use the percentage when it is actually percentage. So here you can have based on the percentage, and you can use different kind of icons, and you can say okay, I got conditional formatting; I can also do that on the brand one. Not that I can't do it in brand; I can also go ahead and do the icon conditional formatting on brand. I can choose a major here, or actually we have a support for a text now. We can say is brand one, is brand two, is brand three, and we can choose different one. Okay, let's choose the four one. So brand one is this. So we can do on the based on the text also: brand one, brand two, brand three, brand four, brand five; only we have five. So we'll get five. There's no option to add here, but we can add more rules and more icons. Add, let's say, is brand six. So we can add more rules, but let's stick with these things. And as you can see, whatever brands we have given some icons, we are getting those icons.
Now, other than that, what you can do is you can create a unique a measure, and then can you—you can do conditional formatting on that; that is another way of doing a conditional form. What is this web URL condition formatting? For the web URL, you need to have the URL basically. So let's see, do we have a URL? I actually have the image URL, but I'm trying to use that. So if you use the URL, then it will start showing you underline here. You want to use the underline. So if you do the web URL conditional formatting, it will start showing you the URLs underly URL. So if you want the underlying, there is an option for URL icon. And what happens when do you use that? For that, let me take one example. Let me open a new page, and in that page let me bring in brand and brand URL. And now let me go to this icon value, value for a moment. I'll change this image URL as web URL, and now you can see the URL here. Now I'll go to the brand URL, apply setting, and in the icon I'll click on the values, and the moment I switch this on, you start seeing this icon, small icon. And this is how you use this URL icon. So you want to show that small icon when you have actually the URL field, you can do that. But as of—for a longer run—I'll just revert it; I'll just shown you how to use that. This is actually an image URL, and the moment I make it image URL, it will actually turn back, and then you can go ahead and play with the size of the image. You can go ahead and say, okay, I want to have 250; you can have that much image. One the limit of 150 has been removed as of now; you can have much higher size of image. So now back to the conditional formatting. So now we have understand different kind of conditional formatting. Now I would like to use the third kind of conditional formatting, which is the value based conditional formatting, which is the major based conditional formatting which we can use in the field value. Let's say I want to color these things based on category or brand. Say okay, we'll go rule based conditional formatting also these days allowed text values isn't you can do that. What I want is a little bit different. So I want to create two majors here: brand color, and there is a reason why I'm creating. So I create a new major from the table tool. So let me create first major brand color. I will also create one more major which is category color. So let me again click on new major, this time from the major tool, and this major I already created, and let me explain you this major. And same way I've created the brand major. So I'm also creating one category color, and now let me explain you both have created in the same manner by using the switch true. Instead of switch true, I could have used switch Max of item category or Max of or selected item category. So when it is category one, I'm giving one color; when it is category two, I'm giving another color; when it is category three, I'm giving blue; let's say category four yellow, and category five orange. So in this manner I'm getting colors, and there's other—instead of other I can make it let's say black. There's no other category, so I can keep it anything I want; it should return color, otherwise it will give error. Now this is a color Mage; it returns a color. You can also use the Hax code, the six digit Hax code if you remember with the hash sign. So if you—it may be hash ff00 something like that—you can also use. So right now I'm using the names. Now what I'll do here is I'll go to this brand by net visual; I go to bar, and inside the FX I can go ahead, I can use the field value; I can go to the major, and I can search for the brand major; I can search for brand color; I can do a condition. Now you can see each brand has got its own color. Okay, so the color is basically by brand, and this helps us when we want to keep the consistent color. So we'll go to this category visual and apply the category color to keep it consistent.
Now in the Matrix visual, I have option; I can have the color by brand or by category. So let's use by brand here. So we want to do the background color FX field value by brand color, and that's where your max is going to play a role now. So let me use brand color, and as you can see, other than the not null values, we're getting color in that particular row. And as of now, the conditional formatting, value based conditional formatting, don't color the blank values; you might have to handle the value itself to get the color. Now we will use the other one, and this category one. Now you will ask how would you use it into the I visual? There's no option; I'll tell you the way. First of all, I'll convert it into cluster column chart or bar chart. I go to the FX; I go to field value; I can do the gradient conditional formatting as well as rule base, but the easier for me as of now to explain to you is field value. I use the color; I created the colors; I'm going to convert it back. Remember the colors take the values, because I'm going to do this now on this visual, which is actually a column visual, which where the conditional formatting is available. So we done it on a column visual; convert it into a pi. Now we are doing it on a column visual again; field value; we clicked on FX, came here; field value color category color. Now if you see the two visuals have the same colors. What happens when we filter something? So let me bring a page level filter, brand one till category four, and category one retained those colors till they are red and yellow, and this is the thing which we can do using this one. We we can have colors which retained it, but only challenge is across multiple measures or with legends it will not work. Also we can't color the Matrix head and row, but how do we color line? We can't color line; only we can show additional colored marker, and this is other than the marker color switch. So what you can do here is again convert it into a cluster column bar; go to the effects; do whatever color you want; I want to do field conditional formatting; I can search the color major and colors, and then I convert it back to the line; I get these markers, colored markers, and these are not same as the marker which we have in the line. So if I enable the marker now, you will say no, no, it is looking like this. Let me showcase you; let me make them bigger. You can see the background; the bigger markers are coming back. So they are not same as the marker what we have; they are different separate markers, but yes, definitely you can show theor you can't color the line, but you can show the colors. So you've seen the advantage of field conditional formatting. Now when we have the field conditional formatting, let's say if I need to do it in table visual, I can quickly replicate it in all the columns, and you know the same kind of conditional formatting, and I can get row colors. Now I have done it on the category and brand, but it doesn't mean I can't do it on measure; I can do it on measure, and we'll take up that example now. Before I do that, I'll go to this cd2, and I knowingly created this because now the colors are going to give a different meanings to this visualization. So if you remember I suggested you instead of using legends use to access. When I use twox, I don't have two colors now; we have because we are going to going to go to the conditional formatting, and from the conditional formatting. Now this is the first one is brand; I'm going to use field value, and the brand colors, brand color I'm going to use, and you can see the different brands have different color. Now you could have used the category colors, and different categories could have colors, and you can use other table visually where you can only have the categories. Now where from where I will get the legend? Definitely you can't get a legend here. What you can do is create a very small table visual, and this is brand isn't it? So I'll put brand here, and you can put the colors to the brand background or font whatever you want. I'll put the background color we value brand, and you can say these are the color of the brand. So there a color of brand one, brand 10 on all those. Now definitely you make it as thin as possible; you can hide the total all those things you can do. Now in the second visual, I'm going to use it on category; it's not going to make much difference, but I just wanted to show you how different is going to look like. You have the category color; I could have used brand color here, and each brand could have the same color. So you can create these kind of visuals using field value conditional formatting also. Rules support the name colors; you can use do do; you can also use rule based conditional formatting that supports the color that also support text now.
Now the final which I'm going to do here is based on a measure, and for that I would like to have a scatter visual. I'm going to create the scatter visual again. So I'll add a scatter visual, and this scatter visual I will have on the x-axis discount percentage; on the y-axis I'm going to have margin percentage; I will use city as my values. Remember I can't use legend; I got so many dots. I'm going to switch the x-axis; I will invert; I want the lowest values on the this side because I want to create a fourth quadrant here, which is low discount, high margin, which is green. How to create the quadrant? So go down; you have the lines, reference lines, and here you're going to add constant lines, not the average line, constant line xaxis constant line, and in the XX is constant line you have this FX, and in the FX use the measor what you want; it switches. Then go to the add line again; use the type as Y axis constant line, and in the y axis constant line in the FX—now choose margin percentage; you have to use the major because major is automatically going to take care of the grand total because it is a divided by B. When you have the grand total is going to do, and when I use the constant lines or when I use these reference line, they are calculated at the grand total level. Now what I need here, this see these are the average line; our ba is given those. This quadrant is high margin, low discount, green. But how do I get this middle margin? I need to—now this is still high margin, but high discount, blue; low discounts are red and yellow; low discount, low margin. Now for low margins I have two: if the discount is low, I can keep it orange; if it is low margin, high discount, I will keep it red. So I need a measure for that; I'm going to create this measure, and I'll tell you how I'm. So let me create a new measure, and I already have a script for that, color scatter. First of all, for that we need gr to. Using calculate discount percent for discount all selected is going to give me the grand total or the average, overall average. Same way overall margin, calculate margin all selected. Why I'm using all selected? So because if you apply the filter, still it find the middle number with those filters. Then what we are saying is: if margin is greater than the average margin and discount is less than the discount, average discount, overall discount, then green; margin is still greater, but discount is also greater, blue; for both lower margins, if the discount is low then yellow; if the discount is greater then red. This is what I wanted; these are the four colors I wanted. I have a major now which can do that. So I use switch through and created this measure. Now I would like to use this measure. So I'll go to the markers; inside the marker color I will use FX, and inside the FX field value search for the color, color skatter, okay, and you can see the four colors: green, blue, yellow or orange if you want it, and red. The four colors have come; we have got the four quadrants of different different colors. So conditional formatting is a powerful tool to communicate the message. The message could be done in terms of value, or it could be done in terms of categorical values. To enhance the visual experience, you can use whenever you require to make impactful visualization.
So let's understand visual interactions. To understand visual interactions, what I've done is I actually created created a few visuals which include table visual, Pi visual, map visual, and bar visual to explain you what are the different kind of interactions which happens between the visuals. I also added a slicer so that you can understand it better. Let me close rest of the panes and give you a space on the page so that page has a larger canvas available. Now I'll click on any of the visual, and then I can go to format and enable the edit interaction. Edit interactions allows you to change the interactions between the visuals. What do you mean by interactions? First of all, between the visual. So let's say if I click on any of these slices, all these visuals are changing. Okay, why these visuals are changing? These visuals are changing because they are interacting with this slicer. If you go to this brand visual, it will only show one value because only one value is applicable because of its interaction with the second brand slicer. Now the moment I erase it, you will again see the values are removed. Now if you click on any of the visual, let's say if I click on Category 2, you will see a different kind of impact which is happening here. Now I'll explain what is happening on the P later, but you see this is highlight which is happening in the brand visual. Actually there's a highlight also happening in the pi visual, but because it's on the
Same level only category 2 is getting highlighted now. I click back, and I click on any of the brands in the P visual. What do you see here? The T table visual is getting filtered, but in the Pi visual, there is a highlight which is happening again. This visual is basically getting filtered. The map visual—now if I go and click again, it will deselect—and here, if I click on any of the city, you will see again a highlight at few places and a filter at other places. But is the slicer getting impacted? No. So, the visual is not changing the slicer unless the joint is bidirectional. So, the visual is not going to filter the slicer, and we don't see any interaction side with the filter pane. So, even if I click on any of the filters, we don't see any interaction changes. So, filters can also filter the data inside the visualization, but the interactions with the filter cannot be changed, while it can be changed for other—what do I mean by interactions can be changed? So now I will click on, let's say, one slicer, and I go to edit interaction and I click on that. Immediately, you start seeing these signs. These signs mean filter and don't filter. So, whenever I click on the slicer, all other visuals we get this filter and not filter, because the interaction with the slicer is either you going to filter with that slicer or you're not going to filter with that slicer. Only two types of interactions can happen. Every chart is a driver chart, and all other charts will become the driven chart when you click on the edit interactions and you try to edit the interaction. So, every chart will become a driver for edit interaction. So, if I click on this visual, you will see the Dr—are you know—now asking for whether they want to get filtered or not. And at some of the visuals, you are seeing three options, not two options. The third additional option which you're seeing is the highlight option. So, what happens if this is a brand? If I click on this, I can disable its interaction with this chart; I can disable its interaction with this chart. So now, when I click on brand one, you see that the other visuals are getting updated, but these two visuals where I switched off the interaction, they are not interacting. So let me erase this. Now let me select brand 10 here in this visual. When I select brand 10 and if I go here, the brand 10 is getting filtered into the other visual, why? Because from this visual, when I click on this visual, the interactions are on for this one. So, when this chart is a driver chart, there is interaction which is still happening; the filter is which is still highlighted. So, each slicer or each visual can filter other visuals unless stopped. Default behavior is filter or highlight, in which case it would be default highlight. I'll let you know—mean, know—let me erase it. Let me click on any of the filters. You don't see any interaction happening with the filter. So, see the highlight is still on the slicer. So, filter—we cannot change interaction with the filter; we can only change with the slicers. Filter is not part of interactions.
Now let's go ahead. When I click on category here, you see that there is a highlight which is happening now. Why does this highlight happen? Because there's a method available. When I click on this chart, there is a method which is available as highlight. If I change it to filter and if I click on any of these categories, you will see—see—now the visual is getting filtered. So the behavior is filter. Same way, when I've clicked here, I can go ahead and change this behavior also to filter. So now this chart will only show the category which is clicked on this table visual. So there are charts where we can show the fill behavior, which include the bar chart, pie chart, tree map. These visuals can show the fill behavior, but charts like table cannot show fill behavior. So let's say if I go to the pie chart and when I filter the default table, can only get filtered, or I can disable filter, or I can filter. There's no fill-pa, so we cannot do it. Using the edit interaction under the format, you can change the behavior.
Let's quickly take one use case: the use case of dividing a page into two parts. So what I'm going to do is I'm going to copy these two visuals from here and I'll take them to a new page. Let me paste them. Let me see—don't sync—also I copied three; let me make it two, or let me keep them three only. So I got these three visuals, and let me—instead of two, I got three—I put them on one side. Now what's happening? If I select a br—everything is interacting. Now let me say Ctrl C, Ctrl V. I get two sets of visuals. Now even if I select brand here, it is filtering across. Now for this use case, let me go ahead and insert a shape, and the shape I plan to insert is a line. Let me make this line bigger and thinner, and I—I'll change its orientation. Now let me enable the formatting, and inside the format I'll go to rotation, and let me rotate it by 90°. So I got a full line—a Y—drawn a line here. I want the left side to only work with the left side; I want the right side to work with the right side; they should not interact with each other. Then how do I change this behavior? So click on this visual. Now edit interaction is already available from the format pane; we have enabled it last time. If it is not enabled, go to the format pane and enable it. Now disable its interaction with all the three visuals. Let me make it a little bit smaller because it's overlapping. Now what would happen here? When I select brand one, it is going to filter the first two visuals, not the visual on the other side. So you can see this visual is filtering; this visual is filtering, but these two visuals are not interacting, and that is the reason why they are not getting filtered. But it will not stop here; I have to do the same thing for here and have to repeat it for all the visuals. So I click on this; I disable its interaction with these visuals. Now I click on this visual and I disable its interaction with the other side. I click on the bar visual and disable the bar visual's interaction with the right-hand side visual on the right-hand side. I click on the P and I disable its interaction with the left-hand side visual. Click on the bar and disable its interaction with the left-hand side visual. Now let's check it out. So if I filter brand one here, only the right side is getting filtered. So I filtered on the right side; the right side is getting filtered. When I click on category and let me change the impact to highlight, let me click on the Pi on the left and change the impact to highlight. See, the left-hand side interacts with the left-hand side; the right-hand side interacts with the right-hand side. There is no interaction between left and right. In this manner, you can change the interaction and create different kinds of interactions behavior where you can decide which visual is going to filter which other visual.
Let's learn the feature bookmarks. Bookmarks is a feature which allows you to create snapshots, and using those snapshots you can create more interactive Power BI pages. Now what happens is there is a facility to show and hide the visuals. So if you go to view and enable the selection pane, which is right now enabled here, so you—to enable the selection pane—and for every visualization you will get the option to show and hide, and you can capture that stage, because sometimes the visual is showing, sometimes the visual is not showing. So you can capture such kinds of situations, and using such kinds of situations you can actually create a really interactive page. What are the uses? There are many uses. Before field parameter came in place, this was also used for switch AIs. So basically, if a visual is on brand and I want to change it to category, so bookmarks along with buttons used to help in that. Then sometimes it helps us in creating a—basically—a slicer pane. So what happens? You can have a slicer pane, and that slicer pane can show and hide. So let's take these two examples of bookmarks and try to implement that and understand the bookmark feature in detail. What I'm going to do is I have another page where I have these two slicers. Let me bring them in. Now these slicers are not interacting with each other right now. I'll say don't sync. So let me change the column on the second slicer. So on the second slicer, instead of the brand, let me use category. So I have a visual which is on brand; I have a visual which is on category—brand and category—and let me bring in one visual also. I bring a visual here; I put this visual here below. Now these visuals are filtering this one. Let's check that out. Brand one, category interaction is happening. Now sometimes, for the space requirement, what you want is I want to hide this region, or you can have it on the left-hand side. So how do I do that? So let me first of all create a pane kind of impression by using a shape. I put a rectangle. So let me remove the color and everything from this one—shape and style—no fill. I think we are fine with the boundaries. Let me bring in the category on top of it. So let's go to the format tab and let's send this backward. So we will say send to back. So this is now on—when—to the back one. Now this is here, and this should—again—let's bring this forward—bring in front. This is also bring in front—control or shift press and right-click—group. So all these visuals are grouped. So we have one group. So what can happen is I can hide this. This is hidden. Now this is one stage where this is hidden. This is one of the stages I want to show. So this is the one stage which I would like to capture, and in that stage I would like to use the bookmark pane, and this is the bookmark pane which is already enabled, and using the pane switcher, let me bring it in. So now this stage, I add a bookmark, and this bookmark—let me call this bookmark as hide enable—and what is this stage when it is showing this? This is show stage. So there are two stages: hide and show. So in this stage it is hidden; this stage it is show. But what happens if I select category one? I removed all the categories in the show stage. I go to hide stage. Do you see this—a category still filtered? So what has happened? When I created this bookmark, actually the data got saved, though the filter is not appearing. So if I go to show, I uncheck it, but if I go to hide and I come back to show, you again see the category one, because the category one was sa—so let me erase this category one. Let me erase the filter and update this bookmark. Now let me hide this. So I unhide it first of all—erase—erase this one. Now I hide it—right-click and update. Now both the bookmarks are saved without values. But let's say if I put category 2 here, let me put category 5 here, and after keeping creating category 5 in the show view, I go to the hidden view. Now if you remember, I cleaned up and saved it again. Now it is—is still showing me everything. So can I pass the values? Because when I show and hide this menu, I still want the values to pass. So for that, we right-click here and we say disable data; we say don't save the data. Same thing on the show; we go and we say don't save the data. Now we go to the show, go to the category and put category 2. Come to the hide view; still category 2. Come back, show. Now let's choose a category where we have lesser values, like category 5. This is the show view, and we go to the hide view; we still get the category 5. It means even if I hide my menu, I will be able to do that. Now what I'm going to do is I'm—I need a button here, isn't it? So I give a small button for show or hide. So I want to hide or show, then I need to give a button. So I will go here in the insert and I go to button. So let me add a very small button here—blank button—I'm planning to add. Let me move it on the right-hand side. I'll go to the button style, enable the text and give it as a name—show. Whenever I click on this, the menu should show. Now I go further down; I go to the actions. In the action, in the bookmark, I'll first of all type—action type is bookmark—what action it should show? It should show. Right now it's already showing. Okay, so we need to do a little bit of adjustment, and then I put another button and I put a hide button on top of the menu itself, and I need to group it. So let me group this together—so merge—I merge it with the group one. So when I go to hide, the button itself is hidden with that. If I go to the show, it is there now, but this should be renamed as hide, and what action it should do? If I click, it should take me to the bookmark hide. So now let's do a—go ahead and click on this. How do we click a button in the Power BI desktop? Control-click hide, control-click show. Shows. Can we apply a filter? Yes, category 2, and we go and apply brand and filter. Yes, brand and filter has been applied. Let's hide it. Till the same thing is there. Click on show; the same thing is there. Okay, so we are—in short—this using the not saving the data with the bookmarks. So these are the stages which are saved, and we are able to create a slicer menu which we can show under it. You can create it on the left-hand side. Sometimes what happens is when you create such kind of menu, you do adjust your visual. So BBE the visual is—see this big—and when it is shown, on the visual is this big. So this kind of adjustment also we do. So with this kind of adjustment, you can try that out. Now the second use case which actually I wanted to go ahead and do is I want to create an impression of access slicer using the bookmarks and button. So we have used bookmarks and buttons and created the menu—show hide menu. Now what we want is now we want the behavior of access slicer. Now access slicer—bookmarks cannot work in a slicer. So what I'm going to do here is basically I will go ahead and create buttons for those and going to create an impression of access slicer. And when you learn field parameter, you will find that the new method is really easy. The field parameter method is really easy, while bookmarks can use for both access slicer as well as major slicer. For major slicer, traditionally also there are many ways available, including the calculation group. Now calculation group has very recently become part of the Microsoft Power BI Desktop. Without going to tabular editor or external tool, you can create it. So calculation group is another easy way to explore that. So calculation group was previously there, and major slicers we can create with the help of independent table; that was also available previously. Unless a very specific case used to come, we never used to use bookmarks for major slicers, but definitely for the access slicer we were using it. So let's quickly take an example. In this example again, what I want here is basically let me bring in this visual by category to this new page. Let me duplicate this—Ctrl C, Ctrl V. Now there are two visuals, and what I'm going to do here is the second visual—I'll change the second visual to brand. So what you want is if you click on—if you click on a button—you want brand; if you click on a button, you want category. So if I hide this, is only category visual, and if I unhide and this—this is a brand visual. So when category is hidden, it is brand visual, and when brand is hidden, we can have category visual. These are two stages, and I want to cover these two stages in two buttons. So I create a hidden brand, and I can add a bookmark, and what will this bookmark be known as? This bookmark will be known as category bookmark. Then I unhide the brand and hide category. What this bookmark will be known as? Because brand is visible, I'll add a bookmark and that bookmark—double click and rename—will be known as brand bookmark. You—you can have a few more versions, and you can have this—so category brand. Now I can ship, but definitely there would be no bookmark pane for the users. So how you're going to enable that? We are going to bring button—insert buttons—there are already bookmark buttons which I doesn't like; there is a navigator also—bookmark navigator. So I'll add two buttons—blank button—but what typically I do is I add the first button, and then I start editing the style, and then I can easily edit it to the second button. So what is the button style I want? I want text first of all. So let me enable and let me call this text as brand. So brand is there, and then I go to the action, and inside the action I enable the action. What action I need? I need a type—action is bookmark—and I want to show brand. So whenever I click on this button, I want to show brand. Then Ctrl C, Ctrl V. Now this second button is going to do the same stuff, but here the action I want is basically category, and this means that it needs to be renamed. So I will go to the button text and rename it as category. So we have brand as well as category buttons. Now control and click on brand; it is brand. Control and click on category; it is category. What is happening? The AIs is switching, or the legend is switching. Now if this would have been the bar visuals, it had been access switching; these are P visuals—legend shifting. You want to change the visualization type—one time it is bar, one time it is table, one time it is Pi—again, bookmarks—you can use so many such use cases can be done with the bookmarks. These are very common use cases which you can do, and bookmarks can increase the interactivity of the page, and it can create a different impression of the page. It looks like much more professionally handled page when you use bookmarks.
So now let's learn what is calculation groups. Calculation group is a Power BI feature which will allow you to apply common calculations across multiple measures. So you don't have to create a measure for each and everything. So this is particularly useful to simplify the measure management, but the feature allows more than that. So if you simply combine the measures, you can create a measure slicer. If you use selected value and you then create a measure—let's say for MTD, QTD, YTD—you can create time intelligence measure by just using selected measures, and then I don't need to create separate measures for Cogs MTD, Cogs YTD, Cogs QTD, next net YTD, net QTD—all those measures I don't need to create. So what we are going to do is we're going to take an example of calculation group where we are going to create two calculation groups: one which will provide us time intelligence using selected measure, which can take a measure which is in the visual and give the value for that as MTD, QTD, YTD; and the second calculation group which we are going to create, its item would be same as what we have—net, gross, Cogs, margin, etc.—but the objective of that would be to give you a dynamic slicer. Both will give slicers that would be equivalent of major slicer. We have also seen in field parameters. To do that, you have to go to the model view, and inside the model view—very recently in the data pane on the right-hand side—we have been given this option—model—semantic model—and using this semantic model you can now create calculation groups. Right now, if you click, you don't have any calculation group. So we are going to create a calculation group. The first calculation group to convert measures to slicer, and the second calculation group for time intelligence. Click on the calculation groups—New calculation group—and this will give you a message: this change will discourage implicit measures. Now you can't use implicit measures. Implicit measure means when I use a quantity column and I say it is sum.
Okay, this kind of stuff would be discouraged from now, and that is why you might have seen every time I'm using something I'm creating a major; this is the something which I know at some stage I'll need. Calculation group, and I'm doing it; we just discussed two use cases of calculation group, but it's a much more powerful feature; it can be used at multiple places. So one of the things which we can also use is basically to use this in small multiples to shift the measures; that is also one of the uses. So now let me create—yes, this will change; this will discourage implicit measure—yes, let it discourage. Our first calculation group has been created, and we are directly landed onto a calculation item. Okay, so we can come here; we can call it as major slicer; we renamed it. Now I go to the calculation item, and there is already one item which is created with selected Imes. Right now I don't want to use selected Mees; what I simply want is I would like to create gross; gross as gross; one item I added, and I'm quickly going to add a few more items. Now net; net; one more new calculation item. So, left-hand side is a name; right-hand side is a definition; cogs; cogs; three is sufficient, and this will act as a major slicer. So we can use it as a major slicer; it is just the collection of measures. Now we again click on the calculation group, and it—there is a button for new calculation group—we are going to use it; new calculation group, and this would be our TI—okay, time intelligence calculation group. So calculation item; calculation group; and name it as TI time intelligence calculation group. And now let's go to the calculation item and rename it as MTD; left-hand side rename, and right-hand side look at the calculation; calculate selected major dates MTD; date of date; this is how we created time intelligence measures in the past also; dates MTD; date of date. Let's close MTD; let's close calculate; we got an MTD measure. In the same manner, we are going to create two more: qtd and YTD in this calculation group. Now I'm using selected major, so I would need a major inside my visualization to supply to this selected major to get MTD, qtd, and YTD. Let's create qtd and YTD; click on the calculation items; on the right-hand side, you will get this new calculation option; click on that and create more; this time we will use copy-paste and a couple of changes; qtd; qtd using dates qtd; let's add one more; so we got YTD; we got qtd, and we got MTD. So now let's go ahead and use this; so I'll go to report View, and inside the report view I'll create a new page, and first of all I'll tell you how do I create a major slicer. So I can see this calculation group; I'll bring this calculation item to—this is showing me three names; I will change this to slicer. Now I will go ahead and create—create a matrix Visual, and inside the Matrix visual what I'm going to do here is I will bring brand on the row; brand on the row; calculation group on the column; it will not show anything because it needs at least one major; I'll go to the majors on the top and bring in net; it doesn't mean it's going to give only net; it's going to give me all three. Now I can check and uncheck or do multi-select using control and get the measures; measor slicer; this is what you have seen, and this is the same thing we are able to achieve using calculation group. Now, now what we are going to do here is—now let's bring in the second one; TI time intelligence one; again, first of all using the time intelligence one, let me create a slicer. So we got a slicer. Now here what I'm going to do is I'm going to add this calculation group on the row; PI; right now you don't see any difference, and I'll expand it; the moment I expand it you don't see a value, and we know time intelligence; we use MTD, qtd, YTD; so unless there is some month where we have the data we won't get it. So let's bring in a slicer for month here; so I got a slicer, and here add data on the date table; month year; and let's go and select a month year where we have data; I'll select July. So as you can see I got MTD value; qtd same because in the month of July MTD and QT are saved; and YTD different. Now if I go to June I will get different MTD, qtd, YTD; and for all three of them I'm able to get it. See, I have not calculated it for cogs, gross, and net; I just calculated it for the selected measure, and there are three selected measures which are coming inside this visualization, and it is able to use those. In this manner we are able to utilize calculation groups to reduce the measures. Now think about cogs, gross, net; three into three; nine majors I needed; I actually did not create nine majors; three majors were already created which I utilized inside one calculation group, and in that manner I've done it. You can do some of those calculations under calculation group items; you don't need to do all the calculations here as measures. So this is one example; now we will use one more example of calculation group where I want to use the small multiple. So if I have this brand-wise net visual—me create a brand-wise net visual—what would happen here is you can usually create a small multiple using, let's say, category, but I want—want to have the small multiple using measures; can I have it? No, because measures you can't drag a measure here; and how do we create multiple measures? Can I use a field parameter here? Let's try out. So we go to measor slicer; we put major slicer here; it takes the major slicer; does nothing. Now let's drag the calculation Group which we have created; the calculation group; major slicer; we put it into the small multiple; and the moment I do it you see cogs, gross, and Nets; three different visuals coming in place. Now let me go to the small multiples; how many rows you need? I will need three rows; how many columns? Only one column; each of them is on the different—different rows; cogs, net, gross; do I need the titles? Yes, I need the titles, but I can go to the Y AIS and disable this shared y-axis. So now the Y AIS would be able to adjust itself. So I removed the shared y-axis so that these values can adjust inside the each Visual, and I will remove the y-axis title. Now cogs, gross, and net; three different measures we are able to use using small multiples. Small multiples is a feature which allows you to have multiple visuals using the categorical variables, but calculation groups allows you to convert measures into Dimension—means into categorical variables—and then you can use it into the places where you could have actually used only categorical variables, and one of the examples is small multiples. So these are the few use cases of calculation groups; you can experiment with more such use cases. Now let's look at the feature field parameters. Field parameter features allows for you to create axis slicer as well as major slicer. Before May 2022, for axis slicer we used to use bookmarks, or we used to unpivot the table and used to create slicers; for major slicers we were using independent table and a major, and then we were also using calculation groups. Now, because of the availability of all these options, I am not showing you how could have you created a major slicer in the older fashion, but let's start this journey of field parameters with axis slicer. I added a new page, and in this new page P I would like to change the access of my visual, and let me bring in one visual using copy-paste. So I have this brand visual; I'm bringing it; brand and net visual is there; I—I'm bringing it; what's happening right now? It is displaying brand; I can go to Home tab and change the type to column; showing brand; can I change it to category? Go here, and you know, bring the visualization pan, and from there you change it to category, but this is something which you're not going to enable for—for the end users. So the—how end users will make it; how do we make this visual more dynamic? So field parameters allows you to create dynamic visuals by changing both axes as well as measures. How do we create field parameters and how do we use it? So let's start with the first thing which is XIs slicer. Under the modeling T we have this new parameter; previously we only used to have numeric parameter; something we have used in top N to make it dynamic, and there are many other use cases. The second option which came in May 2022 is fields, and this is what we call field parameters. Let's click on that. So what your variable adjusts to; Fields; name is access; I want to create axis slicer; so I'm giving a name as access. Now when you drag the fields—remember when you are dragging categorical field—only drag categorical; when you are dragging majors—only drag majors; don't mix and match; that's not the purpose here; brand; category; subcategory; and I can drag from across Dimension; state and city also; I can drag; add slicer to the page; I can click on this; if you don't add then you have to go to—to the data Pane and from there you have to add it. So let me add it and showcase you what is happening here. What this does is it creates a new table, and this table is a little bit different type of what you have seen till now. So if you go here on the pane you will see one table name as XIs, and this table has this kind of a code which is previously not known to us: brand name of item; brand category name of item; category; subcategory name of item; subcategory; state name of geography; state; city name of geography; City; there is order which is 0, 1, 2, 3, 4; you can change; you can even change the names like brand and category; subcategory names; you can also—we got a slicer. Now if I click on this slicer it's not going to do any change to your visual because we have to use it. So now what we are going to do is in this visual—net by brand—first of all build my visual, and here instead of brand now I will go ahead and use access; access; and the moment I do it you still see it on brand; sorting has changed; that is another thing you might have observed; I'll tell you what to do with this sorting. Now what's happening here is basically now if I click on the brand it is brand; if I click on category it is category; if I click on subcategory it is subcategory; if I click on state it is state; if I click on City it is City; it's changing; when I leave everything then I get this expand icon; the expand icon will allow us to now expand; drill next icon to go to the drill next level; drill next icon; drill down icon; all these icons are available because now there are five levels which are available. So if I expand it you will be able to see those levels. Okay, but if you just wanted to keep it for the purpose of slicing the axis you can make this as single select; if you have multi-select you can also select more than one. So now this is axis slicer. One of the problems with the axis slicer and for which you need a solution—so if you go and sort it on brand, let's say—now it is sorted on brand—okay, brand 110—but if I go to category it's not sorted on category; if I go to City it's not sorted on City—okay, a a s l—it started sorting on the major. So to overcome this what you have to do is you have to take help of a major, and this is the trick to make it work. So axis sorting is not happening properly because axis is changing; the moment axis changes it loses the sorting and it starts sorting it on major. So if I go to category then I go to category then I again go here and I say sort on category. So now you go to Brand; it is sorted on brand; you go to category; it is sorted again on net; it is losing. How do we correct it? Let's create one major. So the new major which I'm creating now—what happens is—first of all we need to understand how do we get the selected value because getting the selected value of field parameter is not easy. So we will use sort AIS, but in the S AIS first of all I'll let you know the way to find out what is selected: where underscore cell equals to selected value X's XIs; if I use this and if I try to return this and let's use it on the visual card visual; does it work? We go here and we try to bring it; it actually doesn't work. Now to overcome what we do is in—instead of AIS we use AIS sort selected value, and then what I'm going to do is Max x filter XIs XIs; do order equals to selected value; then give me AIS access; and now let me return this. So now you're getting category; I'm only talking about the case when you do single select; if you do multi-select we have to do a few little different things, but getting this category is not sufficient for sorting. So what we have to do is to create a major switch; switch uncore cell. So what happens if the cell is brand you will say Max of item brand; remember item brand is already on AIS; what happens when brand is brand? I take a Max of it; what value it is going to give me? Brand only; that brand; brand one is brand one; brand 10 is brand 10; brand two is brand two; all those; and in this manner I need to add all of them; so brand; category; subcategories; state and city; for all of them we need to add. So let me quickly go ahead and modify these category. So what I have done here is brand; I Max of item brand; categories Max of item category; subcategories Max of item subcategory; State Max of geography State; I have created a major like this. Now I'll tell you one trick: go to this visual; go to its visualization pane; scroll down; and in the tool tip go and add this major sort AIS. Now when you go to three dots it will show you one more option to sort; that is sort access; click on that. Okay, now you go to Brand; category; subcategory; state; city; all are descending sort; if you might have observed—let's go here; click on this visualization; sort—it is descending; right now ascending; sorted on a state; sorted on a subcategories 1, 10, 11, 12, 13, 14, 16; and then we go 2, 3, 4, 5, 6, 7, 8; this is how it sorts; category 1, 2, 3, 4, 5; brand 110, 11, 12, 13, 14; no; if you want to change this sort like you'll say no, no; this brand doesn't seem one; we do have a brand ID; let's do that. Okay, and subcategory also we have ID, isn't it? Category our five, but we can use ID. Now let's try what happens if I do this. So I'm now using the numeric equivalent measure of that one. So categories 1, 2, 3, 4, 5; subcategories—now you see 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14; brand is 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14. So what has happened is we have not even set as sort column here itself; we are able to do this, and now this sort AIS doesn't matter because it's going to give some value which we are returning something else. So what's happening here is we are able to sort it; correct access sort; is it done? We also talked about that it gives the flexibility to change the major, and how do we change the major? Major is still fixed; it is only net; not coded major here; for that we will create another slicer using the field parameter, and that we will call as major slicer. So we will again go to modeling; new parameter; fields; and in the field this time we will call it major; Majors is a reserved or major table; I already used; so I'm going to call it as a major slicer. When you do that please make sure that you are only taking measures; don't try to bring in columns which are not summarized; it's not going to work great; what happens sometimes you say oh I take the quantity column here; now quantity column is not summarized; not aggregated; is going to create a problem here; that's why I'm only taking measures here; I've taken all the measures; add slicer to this page; yes; I want to add a slicer; click on create; again a new table would be created with the name as major slicer, and a slicer would also be added to the page; we got a table; major slicer with a similar kind of code again; if you now want to rename some of these you can rename into this table; you can call it net sales if you like; press enter; it will become net sales, but still keep on working on that. Now again this is not going to change anything unless we go ahead and add it into the y-axis; we go to this visual; we bring in the pan; the build visual Pane; and there we now go to the major slicer; and from major slicer we bring in the field; immediately the things have shifted; margin; sales by City; cogs; cogs by City; discount by City; and one of the things which you might have observed when you were actually using that major slicer—the traditional major slicer with disconnected table—it has a lot of problems with changing the different type of measure; now it's a percentage measure; immediately it adjusted to the percentage axis; normal measure; I go to brand; category; all axes getting adjusted pretty quickly on different kind of data types. So now you have a fully flexible visual which you can change based on the slices you want to add; two; you want to—you can add two or add three; you can do that; or if you want you can have all of them; you can make it as a single select; you can create two of them and have one of them online and one of them as bars; you can create combo visuals. So in this manner field parameters allows you to create flexible visuals, and these visuals can be really interactive where you can change the axes as well as measures. So add this flexibility as per the need in your Power BI reports and dashboard to get a really dynamic experience. Now let's look at the feature drill through. So drill through is the feature which allows you to drill from one page to another page by passing the filters. Drill through feature is also controlled for what you can pass from one page to another page; means you have the controls, and also you have to decide on which fields you will allow drill through. So let's go to one of the pages here, and let me copy this visual to start with on this—the page one—let me call it as main M1, and let me create another page where I have the visual; I'll again go back to this particular one, and I'll bring in D1 which is detailed one; this visual; now this visual I copy-paste; the category-wise net visual is there; I'm copy-pasting this Visual and converting it into table Visual, and in this visual I will also add brand. Okay, so when we drill from the first visual we will be able to know what brand we have filtered; also let me select both these visuals and create a page D2 and also paste these visuals; and in this D2 page let me have three visuals; and in this visual I'm going to add one more stuff; let me add State here. So when I go to the first page let me add a bar visual here also on the first page; category separate bar is—if I right-click on any of the visuals you don't see any option for drill through; if I click here I also don't see any option. Okay, now go to the D1 page, and inside D1 page at the page level go to the page information and Page type; you can use drill through; the moment you enable the drill through—now this is the newer version of Power BI; it happens like this; if you are on a little bit older version actually under the visualization pan itself you will get drill through option; you can use that. Now how you want to drill through? I say okay, only I want to drill through from Brand; so whenever there is a brand available I want to drill through; so I go to item and I pick up brand; I can pick…
Up category or whatever I want. Now, how does it going to make a difference if I go to page M1 or any of the pages? For the sake of wherever I have brand, if I right click, I will now see option drill through D1. But if I go to the category, I still don't see. Now, as of now, you can't restrict this feature. Mean, once you enable, you can't say it's enabled for this page and that page. So now what happens is you are in any of the page, let's say whenever you have brand and this happens for single value because what ideally you can do with the control, you can select two values and then you can right click, then you don't see it with the control and click. We can select more than one value. If you have only one value selected, like brand 13 is selected and you say drill through D1, the values get filtered and you can see only brand 13. Here you can see the categories related to Brand 1. If you further right click here though there is a brand, we can't further drill from category which we can't drill. Okay, when you drill through, you will automatically get this button, back button on the page where you have drill through and you can click on this control. Click on the desktop, stop, click on the powerbi service, you can come back. Once you come back, you can go to another brand and again you say drill through and D1, that will get filtered and again come back. So we are able to drill through now from D1 to D2. I again further want it to drill on the D2. I click on the empty space on my page. I go and make it s Del through and this time what I want here basically is let people drill from category. Whenever there is a category in the visual people can drill. So what would happen from M1 now from this visual I can drill through to D2. Now here in the drill one I only get D1. I go to D1. Now in D1 all both the visuals have category so either from here I can drill through. Now here it is not showing me brand 8, but brand 8 is there and if I go to D2 now brand 8 do got filtered out. So brand 8 is also filtered. It means anything which is filtered by some mean will carry on that filter to the subsequent page of the drill through.
Now let's go back here and we can further go back on the first page. I'll go to D2. Now from where these filters are, you go to the filter pane, you will start seeing these filters on this page. You can remove these filters if you want. So these are the Dr through filter which are now sometime you don't want to pass everything. So now what I want is when I'm coming to this page I don't want to pass the brand filter, then how can I do that? So you disable this keep all filters. Now before everything getting passed whether the brand was there on the drill through list or not, everything whether it was available in the list or not it was getting passed. The moment you switch off this PE all filters now only you can drill through using category and category will only pass all other values will not pass. So you have to add everything you want to pass. You want to pass City, you have to add it. You want to pass State, you have to add it. You want to pass brand even you have to add it.
Now how different it is. Now let's go to D1 and here we say brand it and Category 2. Now right click here drill through D2. What happens here only category 2 has been drilled through. There is no drill of brand 8. In this manner you can control what you want to drill through also. So you can do multi-level drill. You can control what you want to drill through. Drill through feature helps you for creating Pages which can take information from other page. There is something known as drill through button also. So you can go and insert a button. You can name it go to button style in the text. You can name it as let's say drill. Now when you go down in the action you can use action to drill through and important thing to note, not only you can select a page, let's say I can select a page. You can have FX function. What does this FX function does? It depending on a condition you can change a page. What does that mean? So let first test this button and then let me tell you how to use that conditional one. So click on one of them you will get this button enabled. If you control click to it is disabled. Only one of them then control click on the button on desktop and click on the powerbi service will take you to the drill page. So we said okay go to page D1. What I want is for some of them I want to go to D1 and some of them I want to go to D2. Can I do that? Yes, I should be able to do that. Now if I right now go there is a restriction D1 and D2 on the brand and category. Okay, so now let me go ahead and do one thing. Let me create a major. So I go ahead and create a major and in this one what I'll do is let's use it like this: if is filtered item brand then we go to D1 as we go to D2. So if item brand is filtered then I go to D1 else I go to D2. If it is filtered or not we want to check that. Let let me call this major as drill page. Let me go to the button and in the drill FX I'll call the drill page button. I'm saying I'm going to decide the page. So text is going to show us D1 or D2 and in the action also in the action I'm again going to choose a page drill page D1 and D2. So I click on the brand the brand I filter on brand single brand is filtered. Now brand is filtered. If I click control click I go to D1. Press the back button, come back. I click on category it is D2. Control click this time I went to D2. So I checked if it is filtered then I go to one page if it is not filtered I go to another page. Okay, come back. Now the first time it is showing D2 because we what we have said in our major drill major is that if it is not filter show2. We can further improve upon this one. You can say switch true is filtered item Rand then D1 is filtered, comma is filtered item category D2 else select value you say display select value. Now it is saying select value. Let make it a little bit bigger. So what we have done here is in the text next we have used the same mejor so which is giving the message and in the action also we have used the same one. Right now there is no action anyway it is disabled. Now I when I click it got enabled and I can go to D2 come back. So in this manner you can use Dynamic drill through button. You can control the text of the button. You can also control where it should land you. In this manner you will be able to use drill through and you will also be able to control Pages where it goes and the values it pass.
Now let's discuss tool tip page or report tool tip page. So what happens typically whenever you go to any visualization, let me go to a page where I already have some visualization. You get this default tool. If I go here I also get a default tool. You can add few measures here but sometime what happens is you want more interactive kind of stuff. What I want is basically this category Pi should be shown when on the tool tip of this BR. How do I do that? So for that what you need is basically a tool tip page. So add a new p page. Click on the empty space and in that one you can go and Define a page as tool tip page. When you define a tool tip Page by default it takes the tool tip page size and it you get a small page. So if you go to the canvas setting you will see it's a tool tie page. You can change the size if required. As of now I'll keep of the same size. What we can do is we can add a visual here. So I can add let's say Pi visual. We give the complete space. You can add whatever kind of visual you want. Now in this visual let me add few items. So build a visual enable build a visual. So I'll go to Legend add item category and then I'll go to values major base net. Okay, we can do some font adjustment and all those as per requirement. So we have little bit smaller or something or I can go ahead and on this Visual and I can say I don't need a title. I can go to Legend and text size and I can reduce the text size. Okay, and similarly I can go to detail labels and values and I can reduce the size. Okay, because on tool tip we will be having a smaller one so we can reduce that. So we able to adjust this visual. Now if I go to a page let say I go back to that first page. In this page how do I bring that tool tip page? Our tool tip page was enabled. So click on this Visual and when you get to the format go to the properties tool tip should have been enabled. So enable the tool tip and here by default it is report page and auto here. Now you can select a tool tip page. Once you select a tool tip page on this particular visual you will be able to see that and look this is changing based on the information. Okay. Now if you go here there is no change. If you go here there's no change because we are not use the tool tip page there. Now we have used tool tip page here so it will give me tool tip. Now let's go to another page. I go to a page where in this visual I have both brand and category. Let me clear this off. So now what happens in this page let me on this table visual I'll add tool tip. I'll switch it on page page one is a tool tip page. Now it will only give category because the visual is on category and the category is in the visual it will pass that. I don't want to pass category. One thing I'll do is first of all let me call it as tp1 tool tip 1. So I rename it. I go to this page and I want to do certain changes. So very carefully I need to click on the page properties the canva property and here I have option keep all filters. I uncheck this. Now what should get pass to this page? All things which you want to pass. I don't want to pass category here. I can give all other things which it should pass. So I can give a brand here. I can even give a city and state whatever I want to pass. So State Should pass City should pass all the things which I want on this page to pass I can give here. So these things will pass to this page. Now if I go to this D1 page and I click here you will see multiple categories. The brand is getting pass but the category is not getting passed. Very good. Now let's test it on other things. I go to this interaction page. I do have this page where I have cities. I go to the properties. I go to report page and I enable tp1 for this and you can see with the cities the categories are changing. It means the cities the are getting passed. It's getting passed and brand is getting passed but category is not getting passed. In this manner you can create a tool tip page. Now while adding the tool tip page you should be really careful. The moment you go on the something it will start showing this tool tip. So sometime the user go and want to read a value it will create a hindrance. So very carefully add tool tip page because it suddenly pops up a big value and user may not be able to pay attention to the detail when the mouse is moving. So as per the need add it on the required visuals.
Let's quickly have a look at the AI visuals. So I'll add a new page and inside that new page I will add the first AI visual which I want to discuss with this Q influencer. Now in the key influencer I need analyze and then I need to explain it by something things. So so in the ly let me add brand and in the explain by let me add a major margin percentage. It goes ahead and analyze and the filter is there on the brand one right now. So margin percentage goes up by 0.2%, the likelihood brand being brand one increase by this is the likelihood the brand one going inre. You can change it to let's say brand 10 and it's going to generate the ideas for that. Same way you can also add discount percentage here net and it will keep on generating the key influencers for those. This is one of the AI visuals. Now the next AI visual is decomposition tree. Now decomposition tree expands you to do the root cause kind of analysis and here what you can do in the analyze by let's add a few things in the analyze by. Let me add major I would like to add let's say net sales and then in the explain by let me add item brand category subcategory geography City. Now here what I can do is I can go to this plus button and I can say you know I want to see the high values or the low values or I just wanted to see Next Step by let's say category. It shows me how my category division is there. Then I want to say okay how my categories are doing like say by high values. Okay, I get the subcategories the next level in the next one. I can say okay what is the low values of the brand inside that one the these are the low values of the brand in this one. So in this manner you can go ahead and you know keep on expanding and find out more details. So let's try this. Let me duplicate this page remove this. Let me try to use M percentage measure here. So I'm going to create M percentage measure here. I'm going to Simply use M percentage which is nothing but divide MTD net minus lmtd, comma denom minator which is again lmtd. We make it as a percentage column. Let me use this measure here. Now definitely M need a month filter it can't work without that because I don't have data in the last available month. So I'll put a filter for the month here. Here let's use December. So now the change percentage are coming. So category. So we are having negative here. So we now would like to analyze with this negative how this is performing where it is there. Again we see it's doing good. Let me remove these levels. Me remove this. So Category 3 is doing negative. Let me go to the low values of Category 3 where I'm losing. So I'm losing in these this is a 100% I'm losing. Okay, so let me go ahead and check the category one. Remove the this one. Let me see in category one where I'm losing. Very small. What are the low values uh here I'm losing 93%. So what I'm losing here. Okay, so these are the brand where I'm losing. So in this brand what are the subcategories where I'm what I have. So only one subcategory. Now we know M we are not doing good. So what is that causing this m not doing good? So you can do a root cause analysis using this visualization.
Next visual which I want to explain is Q&A visual. Really interesting visual. It creates questions for you and you can ask. So I can and it is already suggested one of the things which I wanted to create top customers by net. I say okay give me top customers by net sales. It has given me top 10 customers by net sales and the good thing which you can do with this visual is not only you can ask the questions you can actually go ahead and convert this into a regular visual. So here you have a sign here turn this into a standard visual. It creates a visual for me. I add another one and I'll ask another question or top five Brands by margin percent. Top five Brands by margin person and we got it. We can convert this into a visual. There are few settings here person SN names review question teach Q&A and suggest. You can go and Define additional synonymes like net. I wanted to call sales I would definitely go ahead and somewhere mentioned that net is nothing but sales. Whenever I use sales use net. So here if I go down you can see it's already the net is basically sales. So sales is used for net already. It's no name if not I can add it. So in this manner you can modify the setup for Q&A and can make it more effective and you can leave it for your end users to ask questions and get the answers. Other than that there are a couple of interesting visuals like Power app. In case you are using power app you will be able to embed and you will be able to write back. You will be able to start a power automate flow using the power automate. For that you need to have power automate. You can also embed page native report inside your powerbi desktop report or powerbi report and also publish it and then you will have the page inated report also part of this. So these are the various kind of visualization other than the normal visualization which are aailable which you can use. You want to use a custom visual you can click on the get more visual. Make sure you are signed in and your organization has allowed that and one of the very common custom visual which I use is the text filter. Again it is from Microsoft Corporation and let's add it. Now the good thing with this visual is the text visual is that this visual you can search. Let me add to it. So basically I don't need to go and say New York. I can search new. It's filtered. Now what all cities have come. Let me showcase you using another visual where I create a table visual. So these are the three cities which I got or where I use or all these cities I use or. So this is the way you can use text. There are other few visuals and one of the interesting visual which you can also try out is basically play access Visual. So play access Visual is another good one which you can try out. Let me add this. This is by some third party not from Microsoft but what you can do is you can put this play access Visual. I can put month year on this and in this visual I would also like to have a visual level filter that whatever month year I want I only want those month here where net is not blank. Only those months and what I'm going to do here is I'm going to create a visual on which I will use margin percentage on brands or I can use cities. So my Brand's margin percentage will keep on moving in a direction. Let's see. Let me play this how does it behave and the reason for this behavior is right now the interaction is highlight and let me change this interaction. I click on the visual and I go to format edit interaction and I change it to filter. One more thing I do is I go to the column and under the FX I go and write down a rule the margin which is basically from minus one number to zero as a number it should be red plus greater than zero number to one as a number should be green. It will give you a little bit more variety. Right now everything is green. Now let's play around. Every month is showing the brand how they're behaving and you can start seeing the negative values now. So how each brand is changing now you can see that. So in this manner you can use the AI visuals and custom visual as per your requirement.
Let's learn about the card visual. So let me go to a new page and in this this page I will add this new card visual. Now this new card visual came very recently in 2023. It has feature of card visual along with some Advanced feature like you can add images. You can have multiple Majors inside the card visual. So let me make it little bit bigger and I will start adding content to it. So let me add net gross discount and calls on that. So I can add these different kind of
Measures here, so this is one simple way. Now it has lots of formatting properties. Let me click on the format, and inside that, size and style is common. Title is: if you want to add a title, you can add as usual. We have seen we have title, and then we have subtitle, then we have divider. I don't think we require a title unless we want to give it. I don't want to give some Title Here. Let me disable that. Shape: yes, the it is rectangular shape. I like rounded rectangular shape, so I'll do that. But yes, I can change the rounding, or I can use some custom style. Custom style means I need to decide what I want for each and every corner. I don't want to do that, but I just want to decrease it, so I will decrease the rounded.
Then comes the layout. What kind of layout you need? Single row, multi-row grid, and sometime you might not want single rows, so you can have a grid. And once you give grid, it can ask you how many rows and columns I need. I can, let's say, two rows and two columns just right now for the testing purpose. Let's do that. Then the next is go to call out values. Inside the call out values, if you switch it off, you will stop seeing the values. So, and on which series you want to take a decision, you can take a decision of font color, the conditional formatting, all those decisions can be taken on based on the values. You can want to align them centrally, right align, left align, display unit Auto or none. You want to display completely, then you can say none. Then decimal places, I can set up to zero. I don't want any decimal places. If there is no value, then what should I show? NA or blank? I can do that.
Then comes the label, which is on. I can switch off the label, and I will not see any names there. Right now I'm seeing the names, so this one name. I want to make these names bolder. I can do that. I can want to do conditional formatting on the name. I can do. I want them above or below, so the names could be below like this. It was above previously. I liked this one. If they are bigger, you can use text strap and align Baseline. If you want to align to the Baseline, on and off. Then comes the reference label. Reference label for what? Net, for COGS, or what? Let's try to add a reference label for net. We have lot of reference labels, so we have MTD net, LMTD net. Let me add net MTD net. So first of all, let me add a slicer here on the page for month. Here, let me select a particular month. Now I have certain set of values. Now let me go ahead and add some reference labels. So for net, I wanted to add a reference label. Let me try to add MTD major, and as you can see, I'm able to see the MTD. I can enable the title so that I see the MTD value. Now I can also enable details. Details will give me one more major. I can have here. Let me add MM measure. I can add here in the details.
Now to add this measure, what you have to do basically is here, when you have added this MTD, you have to go ahead and select this MTD, and then when you come down, you will be able to add a major. A without that you can't add unless you selected. Now this value is something which is, you know, you might not be able to format it here, so what I need to do is I need to create a formatted major for this one. So I'll go and create a new major. I'll call it M icon, and let me first do without icon. So format M percentage, comma hash, do 0%. I want that, and let me use M icon. Now here, if you want to use M, then you can go and use the display basically none. So now let me replace this with M icon, so I'm able to see the percentage change here, and or I can change it to percent, so it is showing the percentage. I was using the one decimal place, so it was showing that much. So this is now 9%. Now in case you need some icon, so then what we can do is we can use certain Unicode characters. Let me bring in a Unicode character for you and modify this major. I had a previous code which I want to bring it here. I want to append icon, so so I'll use M percent to string. Now there's a change percentage for which I have identified few Unicode. I'm going to use this M percentage there. So if it is greater than zero, I'm using a particular kind of Unicode; if it is less than zero, I'm using a particular kind of Unicode. Let me see what happens now. I'll commit this. Unicode gives us small small icons which we can use. It's giving me these kind of icons. Now I want to change the color also, isn't it? Based on my M chain percentage, I can go to the font color and I can click on FX, and I'll use the rule-based color. I'll use M percentage. If M percentage is less than minimum to less than zero, it's red. Plus M percentage is greater than zero or equal to zero and less than Max, we can write down Max here, then I want to show it a green here, and let's click on okay. It's red because it's coming negative. I can change few months and check it out here. It is positive, negative, so you can see. And similar manner, I can add a few more additional details here to make it little bit more attractive. One thing which I observed: if your reference labels are giving blank value, the properties might go away. Seems like uh there is a null value handling issue.
Now let's go further down. You have option for background on or off, so if you don't need the background color, you can do it. And then there are certain properties which may be applicable at the all level. So if you select all the labels and you come down, then you have few properties which you can basically it's always on that, but you can use the transparency, stylish, solid, width is 1 pixel, ignore padding, all those things you can you can change. Then background, you can change the background color. You don't want the gray color, you can have some other color. Now one more thing you can do is you can add images. Now again, images are individual to the major, so for particular major you can have add a image. You can browse the image and can add it, or you can go ahead and add a image from the URL. So let me add a image from the desktop. I have some images. Let me just take one of these images. Nothing represent new, but let's take one of them. This is a real big image, so fit we can decide, let's say, use a fit or we'll use a fill, and then we can go and decide the size. I use 150 pixel side, but it's reducing my font and giving the problem, so let me use 100. 100 pixel is perfectly suitable. So same way for others, I can also give icons. So this new card visual offers you lot of flexibility, lot of options which you can use and make it really engaging, and using this you can add lot of value to your visualization. And Power BI is continuously improving on these kind of visualization, whether it is new card visual or new slicer, so you can go ahead and try these out inside your Microsoft Power BI report pages and create really give a new level of look and feel to your pages.
New card visual was released sometime back, and in November 2024, small multiples for new card visual has been released. These features allow you to have small multiples for the new card visual. This feature is in preview as of now, and let's look at the details of this feature. So let's have a quick look at what we plan to discuss in this video. First of all, we will go ahead and look at the release notes of November 2024 to understand what is small multiples for new card visual. Then we will go ahead onto the Power BI desktop, and we will enable the new card visual under options and setting and options. Then we will explore small multiples on the new card visual. And finally, we will play around with various settings available for the new card visual small multiples. So let me jump onto the release notes of November 2024. So I am here on the November 2024 Power BI feature summary, and in this feature summary, when you scroll little bit down, you will find the feature which is small multiple for new card visual review. Once you click on that, you will find the details about that. With this month's update, we are announcing the card visual with a new version that retains all the familiar features and update while adding the advanced functionality and improved user experience with all multiple. This feature is currently preview, and the new card visual offering is an excellent opportunity to experience the capabilities of the feature. Small multiples are a series of similar card ties displayed together in Grid format, each representing a category or dimension of data, allowing for easier comparison and analyzing multiple feeds. You will be able to use the small multiples, means the cards will repeat based on categorical variable which you will to provide. The newly feature in has the data organization, visual clarity, and performance, making it easier analyze and present data. Fact to try it: navigate to options and setting options, preview features, new card visual, and make sure it is enabled. That is something which we have enabled in the past, and the card visual has arrived. If you are not using the new card visual, you have to enable that. Another advantage of new small multiples feature is extensive customization it offers, including small multiple layout and choose from single column, single row, or grid, and customize the number of small multiple rows or columns displayed. Advanced formatting option features such as font styles, color coding, and traditional format borders and grid lines. The enable individual controls for border and grid lines permits the customization of style, fit, and transparency. Overflow style options include continuous scroll or pagination to smoothly navigate through the multiple cards without overwhelming the visual space. Headers: choose from the horizontal or vertical orientation, top or left position, customizable alignment, font color, transparency, padding, plus background color and image. These are the few of the features which we going to explore into the Power BI. So this is the summary of the notes.
Now time has come that we jump onto the Power BI desktop. On the Power BI desktop, first of all, let me showcase you my schema under the data model view. It contains my usual sales model which contain a central sales fact joined with item dimension, customer dimension, geography dimension, and date table. All the joins are one to many and mostly single directional. Me go back to the report view and add a page to start today's demo. But before I start today's demo, I would like to tell you the setting to enable the new card visual, in case you have not enabled it previously. File, options and setting options, and in the options under the preview features, inside the preview feature, I have already enabled new card visual. In case you are doing it for very first time, it was unchecked. Press on okay and continue. In my case, I can press on cancel and continue. When you press okay, you might have to close and open your file again, in case it is asking for that. Back onto the Power BI page, and let's call this new page as C. Is on this page, I'm going to add a new card visual. So first of all, I'll open the build visual pane from my right hand side, where I have see all the panes, and from here I'm going to add a new card visual. Or in this card visual, I can add multiple measures, but I want to add one measure to start with. I have added the one major, and as you can see, the net value is displayed on the new card visual. I will go ahead and add brand onto the small multiples, and you can see option of small multiple has also been provided into the new card visual. As I add that, you observe that my new card visual is showing brand, but because of the space limitation, it's not showing it properly. Time has come to provide this visual more space, make it little bigger. Now you're able to see the brand and the net. It's only showing the three rows as of now, and we are going to adjust it using the new format properties which we have got for small multiples. Let's click on the format, and you have got two properties here: small multiples layout and a small multiples header. First of all, let's look at the layout. So single column layout, let right right now we can continue with that, and we use five multiple for displaying the multiples. When the reason I'm not showing 10 because I would like to show you the scrolling as well as the vertical headers. Here it's single column. I could have gone for single row, which will look like something like this. I need to do width adjustment in that case, and I can make it a little smaller if I want, like that. That's the G. Or I could have made it as a grid. Once I made it a grid, so the values like this: brand one, brand 10, brand 11, brand 12, brand 13. I can choose the layouts like how many rows and columns I want. I can make it a 4x4 matrix by choosing four rows and four columns. Now depending on the values and the font size, you can make it little different. So let's go back to the single column layout, keep it five. We have the borders. You can see I can add the additional border. If I add the border, I can change the color, or I can change the width, etc. If I add the border, I can change the width, and if I start changing the width, we'll be able to see the grid lines. In case you want grid lines, go use grid lines. Pay attention here: you don't use grid lines. What happens? Overflow: paginated or continuous scroll. So let me change it to continuous scroll. Now you can see on, and if I make it paginated, you see small icon here, and then scroll down, and you can scroll up using the pagination. Pagination could be vertical and horizontal. That what you can do. The background: in case you want to change the background, I'm not interested in changing the background as of now. And the shape: shape could be a little bit rounded corners. Here you can observe the rounded corners. Now it is column wise with single measure, so I can reduce the width. As we add more measure, we have to increase the width according to that. So these are the properties which I have inside the small multiples and the various stuff which I can change out. I can make the single column, single row, or grid layout, and I can play around with. When I go to the small multiple headers, I have, you know, whether I want the this for one series or for all the series. As of now, I wanted to do the changes for all the serieses, so let's me go ahead and change the orientation to orientation to vertical, and this is something you were asking for long. Now that we need to display it vertically, you have option in the small multiple header for the orientation. Position is left or top. Right now it is left, and I when I make it top, you will stop seeing the data, and this top position will for suited if you go to, let's say, the single row. The top position is more suitable for the single row rather than the single column option. Depending on the requirement, we can play around with the single row, single column as well as left and top. It is just basically based on the need, what suits most for your requirement. It doesn't look so good, so let's change it back to the five, and let's go down and make it from the top to left. There are scenarios where single row will look better than the single column. When you have lot of values, it may be little better to have the single row along with the left. This is giving a different look and feel, and if you want, you can continue with that, but let me make it little smaller. We'll go down and change the position to the top. Now for the top display, I have to again do little bit of visual size adjustment. Vertical orientation. Let me change the number of small multiple from 5 to 8. Is not the most suitable UI for what I'm displaying right now, but I just wanted to showcase you the properties. Let me play around little bit and go back to the single column view and back on the single column left layout. Now on the headers, what we can also do is do the change of the color. So background is on off. I can have a background color, and the background color a little lighter color. I can choose a background color, or I can choose a background image. One can play around with the call out value, enable and disable that, to disable the values. Also we can play around with the label. If you have only one major, you might not want to display the label, but yes, if uh I have more than one value, if I add other major which is gross along with net, now in such case I would definitely like to have a label. I'm having gross and net now, so I need to go ahead and change the layout position to single row in this case. Now this is the layout position of the card. You have a multiple card visual. This is not the layout position of small multiple. This is only layout which we get with the card visual, and we can change it when we use more than one measure to display it correctly. Can choose between the style card and table, and when I choose card, you will see the small differences of individual card display. In this, you can try out the various properties and the option which has been provided with this small multiple option of new card visual. Power BI is putting lot of effort these days to enhance your visual experience, so keep an eye on every month's update what Power BI has stored for you in the future. Why don't you go ahead and try this out?
Now time has come that we understand what is Power Query. So Power Query, you can say, is one of the PowerHouses in Microsoft Power BI. Power Query is the data transformation and data preparation engine. So basically, when you talk about, you know, how do I manipulate the data, how I do I going to make it into shape, we talk about that, you know, in Power BI, we need to have a star schema. Then if it is not in a star schema, how do we transform and put it into a star schema? If our data is not clean, how we are going to make it clean and going to put it into a format where Power BI can understand it easily, or the DAX engine can work better. So that is where the role of Power Query comes in. Everything which you are bringing in into the Power BI is typically coming in via the Power Query layer. So we have the Power Query layer. Post that, the what transform data we got from the Power Query layer, that comes to the models. On those models, we create relationship, create DAX measures, and then create visualizations. Power Query comes with a graphical interface for getting data from the sources, and a Power Query editor for applying the transformation. So you will see that, you know, it has a UI interface basically which is going to help you to do various operations. So those operations are pretty easy, but for everything what you are seeing there, there is a basically code behind that which you can open into the advanced editor and can check it out. Because the engine is available in many products and services, the destination where the data will be stored depends on where the Power Query was used. Basically, Power Query is not only use in Power BI. In case of Microsoft Fabric, we have data flow Gen 2. In case of Azure, we have Azure data flow. There is a data flow in the Power BI service also. So there are different places where, you know, you can have a destination like Microsoft Fabric, Power Data Flow Gen 2, which is also using Power Query to provide a destination option to you. Using Power Query, you can perform the extract, transform, and load ETL process for data. So basically, in Power BI, if you wanted to do ETL, it's natively Power BI ETL, then you have to use Power Query. So let's talk a little bit about Power Query experience. The Power Query user experience is provided through Power Query editor user interface. The goal of this interface is to help you apply transformation you need simply by interacting with the user.
Friendly set of ribbons, menus, buttons, and other interactive components so you have a set of menus like Home, Transform, Data, Custom Column, etc. Using that, you can do tons of operations. All these operations are pretty intuitive; they have been given a name by which you can understand them, and there are steps which perform quite a few complex operations. Like when you go to Pivot Data or Unpivot Data, they are performing real complex operations, but for you it's just one click.
Power Query experience you will get it two places definitely: one is you are getting in Power BI Desktop; another one, you are getting Power BI online. So Power BI online, you will find the integration such as Power BI data flows, Microsoft Fabric data flow Gen 2, Microsoft Power Platform data flows, AZ data factory, wrangling data flows, and many more that provides the experience through the online web pages. These are online experiences, and as you know, your favorite Power Query for Desktop found integration such as Power Query for Excel and Power BI Desktop. So both in Excel and Power BI Desktop, we do have the Power Query experience.
What Power Query uses internally? So Power Query uses a language which is known as M language, which is basically for the transformation. So the Power Query engine uses a scripting language behind the scenes for all Power Query transformations. The Power Query formula language, it's known as M. M language is the data transformation language of Power Query, and anything that happens in the query is ultimately written in M. So basically, if you're doing an operation, Pivot Operation, so there is some function of M which is getting executed, and then you're getting that. So what will happen when you open the Advanced Editor? You will be able to find out the code. So right now, at this stage, we'll not discuss what is inside this Advanced Editor. As you become the advanced Power BI developer, you will be able to see that code inside that one. And in our beginner series, we have discussed quite a few functions. All the Power Query functions which you can use have been discussed in the beginner series; all the table functions, the list functions, all these have been discussed in detail there. So please go ahead and also watch that series. Means once you are a little bit comfortable with this one, there are quite a few videos in the beginner series which you will be able to watch. So let's move ahead.
If you want to do Advanced transformation using Power Query engine, you can use Advanced Editor to access the script of the Power Query and modify it as you want. As I said, you know, Advanced Editor is there, and we do manually write down the script. If needed, you can modify the script as per our requirement; is all we can do it. It is not only the graphical user interface which is going to do everything for us. If user interface functions and the transformation won't perform the exact changes you need, use the Advanced Editor or the M language to fine-tune your functions and transformation. We can go ahead and, you know, change these things, and sometime we solve the complex problem; at that time, we realize, okay, it's really difficult if I simply try to combine some steps. So we go ahead and, you know, write down manually the Power Query code.
So now what we are going to do? We're going to go ahead, ahead, and look at basic operations of Power BI which you must know as a beginner, and then from there you can pick up and can do more and more complex transformations. You can combine transformations and solve some problems. You can go ahead and write down, you know, nested functions of M language and, you know, create your own solutions around it. Let's understand data transformation, and which is also known as Power Query. So what happens is when we start data loading, especially in the import mode in the Power BI, the data when it gets imported, the first place where it lands, it is into the data transformation mode. But what happens is most of the time we just simply load the data, so we are not aware that the data was actually passed through the Power Query layer or the data transformation layer. Power Query transformation or the transform data layer is really strong, and we can do a lot to improve the quality of the data. It is kind of an ETL data quality improvement data transformation engine.
So let's begin by using the Power Query. Typical way to reach Power Query is Transform Data. So when you do this, you will reach the Power Query layer. But when you load a new data also, you can, instead of loading the data, you can use Transform Data, and in that manner, you can also reach to Power Query. And we will use the same method for this part of the video. What we are going to do is we are going to use this file, Pivot Data.XLS, which is again available on my GitHub account, and you'll get a link. Right-click on the raw copy link and go to Power Query. Click on Get Data, Web, give the URL, click on Okay. You got a popup; there are quite a few things which are available in this file, and what I'm going to do is I will take most of these things, and instead of Load Now, I will use Transform Data. Transform Data will take me to the Power Query module, and Power Query module which can be used to transform data. Also, sometime when you have a huge amount of data, you don't want to load it directly; you can come to this module and reduce it, the data not in final shape, just like the data we have loaded right now. You can come to this place, transform it, and then start loading it. You have an option here for Close and Apply, which you can use once you're done with the transformation. Apply, stay here and continue. Close and Apply means close, and the changes would be applied, and you can go ahead and analyze that. Various tabs and the most important tabs which you're going to use for the transformation is Home tab; the tons of transformations available here, then the Transform tab. This includes a lot of transformations; add columns, not only you can add the columns, but other than that, there are transformations which can be done while adding the column; you can do that. Then inside the View, you have the column quality, column distribution, column profile. If you are now looking at the data, you might be seeing that, you know, it is showing the column distribution right now. Distribution means how many distinct values you have and how many unique values you have. Might ask what is the difference between distinct and unique? Distinct means how many distinct values I have; like a, b, c, d, nine values I have, distinct values. Then what's the difference between distinct and unique? The distinct values which are non-repetitive. If you look at the second column, it is saying there are only two values which are basically non-repetitive. So if you see 78, it is actually repeating. Okay, if you look at 56, it is actually repeating. So one of the value, distinct value is 56, but it is repeating. If you look at 90, it is one of the values which is distinct but repeating. 80 and 45 are the values which are the distinct which will become part of the distinct values, but they are not repeating. So that's how unique and distinct are different. Then you can also add column quality. Column qualities give you valid, error, and empty. So the data which I have is empty, but if you have a data like this one, you have the empty rows; 25% of rows are empty for this particular column. Then then comes the column profile. Now column profiling is pretty strong; it provides you a lot of information like count, error, empty, distinct, unique, empty string, min, max, and if you have a number column, let's go to a table where you have a number column also. So here in this one, we have a number column. So in the case of number column, it will also give you min, max, average, standard deviation, odd, even; so so many things it will tell you. So if you want to know more about your data, then you can use column profiling, column quality, and column distribution under the View tab.
Now you learned about these column profiling, column distribution. Let's also pay attention to the panes on the left-hand side. We have a pane where all the queries have been given. On the right-hand side, all the steps have been given. Whatever you are doing here, here every step is getting captured, other than this observation of profile. So how this data came in, what was the source, the Excel kind of a source we had, then how the navigation has happened, you selected a sheet, fail sheet, then promoted the headers, the headers have been promoted, change type, type has changed. Now any transformation you do, any column you add, other than the rename queries, everything is getting tracked. And what would happen? All these steps, you can look, what was the previous stage, what is the current stage, and these can be reverted. Middle steps can also be deleted, provided the next two steps can adjust to each other; otherwise, it they will give an error. So everything what you're doing is trackable here, unlike DAX where you create a formula, you know the formula, but you don't know whether you created formula A before or formula B before; you don't know, but here anything you do, you do rename, you do transformation like we are going to do Pivot Data, Unpivot Data, Merge Data, Append Data, everything will get tracked here. So it is not a process where you are not aware of the steps; every step will be captured and will be shown to you.
Now let's look at this data. The Pivot Data, is it in the final shape and ready to be analyzed? No, it is not. The data is basically pivoted in the Excel; somebody has moved the subjects on the columns, and this is a pivoted data, and to make this data more suitable for analysis, we have to unpivot it. So we have to go to Transform Data, and there we have an option for for Unpivot, Unpivot Columns. Unpivot Other Columns means other than what you have selected. Like right now, I can do Unpivot Other Columns. I selected Name; I can Unpivot Other Columns, Unpivot Selected Column, Unpivot Columns. First step, can decide whether it needs to do other two, Unpivot Selected Columns. Whatever I select, let's say if I select from here to here, Math to English, then I will have to go and say Unpivot Selected Columns. When do I use Other Columns or when do I use Selected Column? What happens if you have something known as Month on the top? It is possible that the number of months are going to increase, so you will get more months in the columns. In such cases, select the Name kind of the column or the fixed categorical column and use Unpivot Other Columns. Now you may come back and say, no, no, no, the column which needs to unpivot remain same, but the attributes may increase. So with the Name, I can get Age tomorrow; I can get some other property; the subjects are going to remain consistent. In such a case, we will use Unpivot Only Selected Column. So here we'll click on the Name and use Unpivot Other Column. Once I unpivot it, it is going to give me Attribute and Value column, and these Attribute and the Value columns are the one which has made my data now more suitable for analysis. What I can do here is basically in the last step of Unpivot Other Columns, I can go ahead and change the name to Subject and Marks, but don't do this in all the Power Query steps unless you understand that you can change them.
Let's have a look at this data. Is there something wrong with this data? Now this data you can work with, but there's something wrong actually. The majors which I have, they should be the columns, but they are on the rows. So Sales and the Margin, both editable; this is Margin number, not percentage; they're actually in the rows instead of column, and that's the problem with this data. So basically, this data is something which is already unpivoted, and I want to pivot it. And to correct this data, what I'm going to do is I'm going to select M and Value; I'll go to Transform, and I'll use this Pivot Data option. I click on the Pivot Data; it will ask what is the value column, which is the column you want to Aggregate, and then what is the kind of aggregation. Now here I have one value which is doubled up. So if you don't have any value which is doubling up, you can use Don't Aggregate, but there is one value which is doubled up, and that's why I wanted to first select Don't Aggregate and want it to show you that is going to show me an error for that. So if I use Don't Aggregate, it will going to show me an error because there are two values for this particular combination. So it says this, it's getting a list. So what I'm going to do here is I can go to the gear icon here at the last; there is a gear icon; I can click on that; I can go to the Advanced option, and instead of Don't Aggregate, I can use Sum, or you can delete this step and edit again. Let me do the Sum, and now I'm getting the correct pivoted table. The data was unpivoted from the source; I pivoted it; I can use now Close and Apply to use this data, but we'll continue to do more transformations.
What's wrong with this data? Quite a few things; the header is not placed correctly; there are full blank rows, and sometime what happens you are bringing in Excel data; you may get full empty rows at the end; somebody might have traveled through that Excel sheet, created those empty rows. So how do we remove those completely empty rows? The problem doesn't end here; in this data, I see complete duplicate rows; the rows are completely duplicated. So I want to remove; by data doesn't have complete duplicate rows; that's kind of data I want it to have, and these are few transformations which I need. So let's start doing these transformations. So first transformation I want to do is I want to make the first row as the header. Under the Home tab, we have an option, Use First Row as Header. Let's do this transformation; promoted headers, transformation has been done along with the change type. Now the second transformation which I need, want to remove the blank rows. So under the Home tab, we have Remove Rows and Keep Rows. This time we are going to use Remove Rows. Under the Remove Rows, you have Removed Top Row, Remove Bottom Rows; you can give the number of rows you want to remove. Sometime what happens you have a report where some additional stuff is there, and then you are using that; you might have additional R than the top; there is a report where bottom something is written, you don't want; so remove the top and the bottom rows, remove alternate rows, remove duplicates, which is the next step you want to do, remove blank rows, the step which you want to do right now, and remove errors if there are some error rows. Let's remove those. So remove blank rows, completely blank rows we are going to remove, and it removed the blank rows. Now the next thing which, so now there are no blank rows. Now I want to remove the complete duplicate, but when you are doing this operation, you need to be little bit careful because if you select a column and try to do that operation, it is going to be little bit different than the operation which you want to do using the complete table. So here, because my rows are exactly duplicate, what I need to do here is basically click on this so that no, no rows is selected, and then go to Remove Rows and use Remove Duplicates. Look at what it is done; Table Do Distinct, Remove Blank Rows; this is the step I want when I want to remove complete blank rows. But let me go to another one here. If you see in this row, I have 9, 90 duplicate; there are few null values. If you go here, Remove Rows and use Remove Duplicate, you see what has happened; just taken a column name; the duplicates are not the row duplicate; it is the particular columns duplicate which has been, so you know the difference between two; the column would be column duplicate; it may happen that there are no row duplicates, but when you delete it on the column, the duplicates get removed. So the column duplicates, because of that, the complete row got deleted. So be careful about that; I don't need that right now. And the beauty with Power Query is remove the step back at the previous position. So now what's wrong with this table? Actually, there's nothing wrong; this is a perfect table, but there is something which you want to learn; it's not the best example of the table what we can have here; I want to learn something known as in the transformation, Fill Up and Fill Down. In the Maths, if you see after 90, I don't have any marks, and what I wanted to do is sometime you have, what happens in Excel, you create those five kind of a table; 90 is repeating, so only one 190 will come. Now I want to do the Fill Down, so it should fill in the 90. So under the Transform tab, you have this Fill, Fill Down. So 90 will repeat. Now in the case of Physics, there's only upward movement; means there are blank rows, and then we have a number. So here I will use Fill Up, under the Transform tab again, Fill Up. Now in this column, I could do any of these operations; in this, I can also do any of these operations. So Fill Up and Fill Down, it takes the value on the top; if there is anything which is blank, it's going to replace those values with the last available value, and very useful transformation, very difficult to do otherwise, but Power Query made it easy. So this kind of transformation is something which enables you to improve your data quality; they are available inside the Power Query.
Now let's come to this table, and in this table we wanted to learn the feature of Replace Value. Now first of all, this table is not in the proper shape. So what I'm going to do here is now instead of going to those options, I click CLI on this table icon, and there are options here, and the one of the option which is there is Use First Row is Header, and I'm going to use that. Now I want to learn Replace Values, and the objective is twofold: how do we replace null values, how do we replace any other value, and how do we replace some value with the null value. So we have this Replace Value option; on the right click, we have Replace Value, but it is going to replace in this particular column only. What I can do is I can select multiple columns also with the Shift, and under the Transform tab, I also have Replace Values, or right-click, Replace Values. So you can go, go to Replace Values. What I want to replace here in both the columns, what I want to replace, there is a value called known as GG; I want to replace this value with ABC. It's available in both the columns if you observe that here and here. Now there are Advanced options, Match the entire cell content, Replace using special characters. So I can use the first option now, but I don't want to use, let it replace. So you will see there was Triple G here, and because there was a Triple G here, and it replaced the only 2 G's. You can go to the back, previous tab, and see this is Triple G where only two G's were replaced; the first match was get. How do we replace the null values, or how do we replace something with a null value? If you see here, this column also has null values; this column also has null values. Click on both of these columns with Shift, Replace Values, and for null you have to write down NULL, and then you can replace it with the value NA. But if this null is NL null text, then I'll tell you the one quick fix for that. So once you do this fix, and you can see the null values are replaced with NA. Now if this null is a string, you can do the same step and come back here and put this null into double quotes. You will see the formula here, and this is the step; in that step you can go ahead and replace. If I do here right now, this will not find any null value, not replace it; the null text value. Go ahead and change this. Now what I would like to do here is this hyphen; I want to replace this value. I clicked on that, and I say I want to replace this value with what? I want to replace this with null; Replace with null; click Okay. So it's again giving Replace Table, Do Replace Value in the last step. See every time it uses the last step; Hyun with null replacer, Do Replace Values, Item Category column only; in that particular column we have done it, but if
You look at the previous steps; you find that it has been executed on multiple columns. You can give n number of columns, and then you can execute on that. So this is replace value for you. So what is wrong with this data? The data itself is transposed; so the rows are on the column. The columns are on the rows. The date should have been in the rows; they are in columns. The major sales and margin should have been the columns; they are in the rows. So we need to transpose this. So click on this table icon so that nothing is selected. Supp that, go to Transform Tab and use the option transpose. The data will get transposed, but still it is not correct or the final shape of the data. The first row contains the header, and to overcome that, you will go to the Home tab. And inside the Home tab, on the right-hand side, you have an option: Use First Row as Header. Also, when you click on the down arrow, you have the reverse option also: Use Headers as First Row. Sometime it may happen that you bring in the data and you don't have headers; it may create the first row as header. We want to revert it. So as of now, I'm going to use the Use First Row as Header. So the first row which I have, the row number one, should become the header. And this is add an additional transformation for promote data. And after the promote data Power BI do try to change the data type to correct your data types automatically. And as you can see in this step, it has automatically detected the correct data type. So this is the additional step which has been added, and because of this step, you now have the correct data type and you have the correct format.
Also, let's now learn the operation merge, which is basically the operation merge. What it does? It can join the two tables. You can use any kind of join like inner join, left join, right join, and anti joins also. I'll explain you what those are and can combine two tables. So I have couple of tables which I want to merge basically, and the merge is basically the you matches the rows and then you merge. It's not up and one below each other; that's not the merge here. So merge here is basically you join them. So what you call in the SQL joining two tables using the joins here? Actually, we going to create a new table or new query when we join them in the Power Query. You usually call it query when we join and execute. So I basically have two tables here. The first table is master table; it's not true Master; it has couple of duplicates, and I have knowingly kept those duplicate that what impact duplicates can have. Pay attention to the category IDs which we have: 1, 2, 3, and 5. The second table which I have is the detailed table along with which I want to merge this. Pay attention to the category IDs: 1, 2, 3, and 4. So five is there which is not here, and four is here which is not there, and I have kept it for a purpose. And category ID 1 is repeating here or couple of rows; category ID 2 is repeating, but not going to play such a major role because it is expected in the detail it is repeating, but the one is repeating in the master also.
So now let's start our journey. We can click on any of these tables. I'll start by clicking on Master, go to the Home tab and use Merge Queries. I will use this down arrow because it giv me two options: Merge Queries and Merge Queries as New. If I use Merge Query, it the data would be merged in this current table, but I would like to use Merge Queries as New. This will allow me to create new tables, and I'll keep on explaining you different kind of joins. Merge Queries as New, master table we got it. Let's click on detail table. How do we join? Click on category ID and go and click on cat ID. If you have multiple columns, assume you have then Control Plus click will give you the options. So here again, Control Plus click, you want to remove again control and click. So I only want to do one, so I'm doing only on one column, but you can do it on multiple columns. The first join I want to do is inner join, and what does the inner join do? Only matching columns, whatever rows are matching, it is going to do that once. After selecting this, I'll click on after selecting this, I'll click on okay. It is showing how much is matching, and definitely not everything is going to match because we have some missing IDs on both sides. So let me click on okay, and as you can see it has given me a table, and right away in the table table first is going to be complete, and table two we need to expand. But you can see the missing id5 here. Let me expand and see does it make it any difference. So when I expand it, it ask me what all you want. Right now I can choose to get everything, and also I'll uncheck this because this is going to prefix the table name otherwise. So I'll uncheck this: Use Original Column Name as Prefix. So I got this data. Now if you see here, observe this: the cat ID one is now four rows, two from the header and two from the detail. So it became four; Cartesian product is happening 2x2. So that is why we our master table should never have duplicate; we could have done remove duplicate before this. Now this is inner join, and because of the inner join we have lost four and five, four in the details and five in the header.
Now let's go back and let me rename this table first of all. Double click or right click, rename inner join. As you might have observed that this has not added a step; it means this thing cannot be reverted. Now let's go back to the master again. Follow the same flow: Merge Queries, Merge Queries as New, master table is already there, select the detail table, category ID, cat ID, and this time we are going to do left join. What does left join means? All from the first and matching from the second. So whatever is matching and if there are multiple rows getting generated because of that, it will generate that, but whatever is left out which is not joined, if it is part of the table one, it will bring that, and all those corresponding value from the table two would be null for that. So that's left join: from you all from the first and matching from the second. It is showing how much match you're going to get, and let me click on okay. Now again we get the first table columns and expansion for details. I'll expand it and let me click on okay. It has unchecked that because last time I unchecked, so it will remain unchecked, and let me click on okay now, and as you can see we got category ID five from the header for which we don't have any corresponding data in details, but because of the left join it is coming in. Let's rename this table as left join. Right click, rename left join. Let's go back again to the master table, Merge Queries, Merge Queries as New, master table, let's take the detail table, category ID, cat ID, the join, and right join. Right join means all from second. So the missing ID, so the additional ID four is going to come now, but we will miss five because five is on the left-hand side, but what we are saying all the matching things will come from the details plus additionally whatever the details contain that will also come. Let me click on okay. Now this time you start seeing a null row already; it means there's something which is coming for which we don't have a value in the left-hand side of the table. Table on the top is here in the left. I expand the details using this expand icon. I'll include all the column; just press okay. And as you can see we have one row where we have category ID 4 which was not present in our table, the master table. Let me rename this right join. Let's do the journey again: Merge Queries, Merge Queries as New, master table, detail table, category ID, cat ID, and this time we'll use full join. From both matching will match, and whatever is not going to match from both the tables is going to come. And again it showing what is matching, what is not matching. Let's click on okay. You see a blank row; you see category five also. Expand. Once you expand you can get all the column in, and you will see now both the rows: one from the left side having blank because category ID 4 only exist in second table, one having Blanks on the right-hand side, no blank on the left because Category 5 does not exist in the detail table. So this is full outer join for you or full join for you. Let's rename this as full join. Double click, rename.
Let's continue to now two interesting kind of joins. Click on master table, merge query, down arrow, merge query as new, master details, category ID, cat ID, and the most interesting join which we could use is left anti and right anti. Let me use left anti this time. Row on only from first, something which exist in the table one or the table on the left-hand side which is not present in the right-hand side table is typically category id5 which is not matching is going to come. That two for the left table, so non-matching rows is come. If you remember we have something known as except or minus set operation, something which is present in the table one or table A and not present in table two or table B. So you will see we are having the category 5 row is coming in, and we know there's not going to be any match data in the details, but anyway we can expand and check it out. Actually, after this join there is no benefit of expanding, but to understand this we have expanded it. So this is left anti. Now let's go back to the master again and try the last join we wanted to have in the Marge queries, Marge queries as new, and we are going to try write anti with the detail table. So master in detail, category ID, cat ID, right and join only the rows available at the right table, the bottom table here. In this case, whatever is only available in this table which is not matching with the master table is going to come here. Let's click on okay. It shows one row with a blank, and when we expand the detail we will see category ID 4 coming in here, and there is no data on the left for that. So the row which is not having a matching data which is on the right-hand side is coming here, and that is right anti join for you. Let's rename. You can use these Marge to combine the tables in Power BI. We prefer star star schema, and sometime you may come across a situation where the tables are not in Star schema. In such cases you can use Power Query to create star schema if required. Sometime you may want to duplicate the tables to do that because in the star schema facts are self-sufficient. So let's say you have a header table; header act as a dimension as well as it need to be merged with the detailed table. In such cases you can duplicate the table and use it. So how do we duplicate? Click on any of the table; let's say I have this detailed table. I want to duplicate it. Right click, duplicate. Don't use reference; it going to reference that. So you can call it as detail 2; it's getting duplicated, and then you can do your Marge operations. We had this detailed table, and we duplicated and created another detail table to let me go ahead and add one more column here. How do we add a column? We can simply add some formula, or I can split it, or to add a column, or I can duplicate it. So you can right click and duplicate a column, and let me call it as a name Tool. And why am I'm doing this? I want to show you something known as operation Upend. Operation now upend operation is typically you want to Union the data; you want to combine that. So the operation which is upend here is kind of a union all; mean it's just going to append the rules. Second is unlike the SQL Union or the Dex Union where you need the same size of the table or the same number of columns in the table; it's not necessary. And that is why when I had a detail and detailed, I just additionally added a column in the click on any of the column, click on any of the table, and then go to append. Again you have two options: Upend Queries and Upend Queries as New. So what I want to do here is basically I want to use the append queries as new. So let me use append queries as new. Now detail is the first table. If you have three or more, you can use this particular UI. For two tables you can use this UI, first table, and you can select the second table, and the second table which I wanted to select is basically the details table, details table and details two table. Let's click on okay, and as you can see that the both the tables are appended one after another one; they just comb just combining the tables with all the possible column. There's no deletion of duplicate here, and definitely I have now created a new additional column. So it's not going to delete any duplicates. As you know we have removed duplicate option in case we wanted to do a union all kind of operation, we can do that. Now in this case you can see that the additional column do have come which is part of only one table, and the rows are blank for the table for which it was not available, and the other table where it was available it has come. Now post this if you want to delete duplicate, now the delete duplicate can happen based on ID column or based on the complete table. Now here I would like to delete the duplicate based on the ID column. I can click on the ID column; I can go to remove rows and remove duplicates. So I'm trying to do kind of a union operation in the SQL world where you actually don't have duplicates. Now in this case definitely it has taken a decision to take some set of columns from the of the tables when there are multiple values available. So in this case this has taken the name to where the null values are there. You can append; you can remove duplicates and create a union or Union all kind of a scenario based on the requirement.
Let's learn how to create a custom column in Power Query, and for that what I'm going to do is I'm going to add the same file here, the sales file which we have used, and the reason for that is basically because I want to show you the same formula which we created there. So let me go to the github.com, and in GitHub this is the file which we are using: say data used in video. Right click on the raw, copy link, come back to the Power BI, and now I'll tell you directly from the Power Query under the Home tab. If you click on the new source, you will be able to add new sources from here. Go to new sources, click on web which is available directly into the menu, give the URL, click on okay, and I load only the sales here. And now you don't see the button of load data and transform data; this is only okay button because when we opened it from Power Query it's going to put us back onto the transform data mode only because it has put us into the transform data mode; it is not asking for the option whether you want to load the data or transform the data. So we have to transform the data. Sometime we may get this kind of error; you can simply refresh. Now if you remember we created few columns there; so same column we wanted to create here. We will take one or two example of such columns and also create some different kind of new custom column. So once you are on the table, you can go to Add Columns, and inside the Add Column you have: Column From Example, Custom Column, Invoke Function, Conditional Column, Index Column. Now the first of let's learn Index Column. What is the Index Column? Sometimes what happens you are bringing in a table and you don't have row numbers, and row number is required sometime because I want to create it as a dimension; means I I went ahead and I remove the duplicate and I created a dimension; I need a unique number. Then how do I do that? I can add Index Column. Sometime you require row number just because in a visual you want to display and Power always summarized, so you need one unsm column. So in that case you can add Index Column. So you can add Index Column from zero or from one, or you can even modify it. So I added an index column; it is a unique rule number column for me. I can decide from where it should start, how much increment it should have. So if I want let's say two to increment, I can make it two. What would happen here is it will become odd numbers. I want to start it from let's say three; I can make it three, and it will start from three. These changes I can do; let me make it one and one. Now this is one type of custom column. Let's go ahead and add another kind of custom column which is basically Custom Column B. What I want to gross? What is my definition of gross? Is quantity multiply by price. Now here uh we have no option to select the data type, but in the Power Query online version the data flows we are getting that option to select the data types. Here we don't have. So let's click on okay, and you will see it doesn't take a data type here. So what I can do is whatever data type I want I can give that as a last argument. So be on that step, put a comma and use type. Let's say I want in 64 or decimal. So here I can give type number on numeric, and let's try this out, and it has become the number data type. So in this manner if you remember the type you can give the type; otherwise you have to use the option here. You click on this number column or ABC what was written and you choose the data type, and it will add a step for that. To avoid the step I simply written type number because I remember that it can be added like a number. Same way you can add another custom column for cogs, and that is nothing but quantity multiply by cost. Now you can if you use this here, you click on this number column or ABC what was written and you choose the data type; see it add additional step, but that is why just to avoid this additional step I had this script. I can remove this and go ahead and put a comma and put the third argument which is not available here. Now the new column which you created you can again use them in creation of columns like discount amount. You can go here and create discount amount; you can use the column which is previously created, which is nothing but gross multiplied by discount percentage divide by 100. If you remember the discount percentage is absolute, and that is why we need to divide it by 100. Again I can change the data type. Now if you want to create a conditional column, you have option here to create a conditional column. So you can click on that and you can write down a conditional script. So if let's say sales date equals or less than equal to or is after we say before what date we say okay it is before 2019. Let's go by years. Now go by month. Double Arrow, take years, is before 1 January 2019, then one else zero. Data before 2019 and after 2019. So you can create a conditional column. So it will give you values and what all values we have if you they are not loading; we can click on load. So we have both one and zero values depending on the dates we will have value. It will always load a sample side of hous and rows, and based on that it will do the column profiling here at the end if you see. But if you want all the rows you can actually click here and you can use on entire data set. It is especially useful when you go to the view and you do this column distribution, column profiling, then you can use that. Now again I can change the data type, but right now I'm leaving that. Now I can add this column manually also. Actually, I can go to the custom column.
and I can write down the condition of my choice. So let's say, test if quantity equals to one, then unit one, else many. So I'm saying if quantity is equal to one, then one, else many. This kind of condition I can give, and I can have multiple if else to create complex conditions. So one and many, one and many. Usually, I have quantity one, two, and three, so I'll get one and many for many. For two and three, I'll get many in this manner. You can create quite a few custom columns.
Now, some cases you have this additional column which you can create. You can add a column, um, so you want to measure a length. Let's say you want to measure the length of this column, but I don't want to use a transformation. I don't want to change this column; I want a new column. You can go to extract and say length, so it will actually give you the length of this column. Same way, other operations on length like first character, last character, range, text before delimiter, text after delimiter, text between delimiter. So what happens in all such cases, it will actually go ahead and add a new column. So instead of transforming the current column, sometimes you don't want to transform the current column; you actually want the information in the next column. So this is really helpful here.
Same way for parsing, if you have an XML or JSON column, you can parse and other one you can like format like I want this uppercase or lowercase, but I don't want to transform this column; I want a new column, so I can go ahead and use this. So this will add a new column. Just for an example, let me use this lowercase, and this time instead of making this test as lowercase, it actually created a new column, lowercase. In this manner, you can add custom columns in Power Query.
So most of the columns where you require multiplication kind of a stuff, you can add them in Power Query. Conditional column, you can add them in Power Query. Other transformations which are needed at row level, you can pretty much do all such columns in Power Query. There are formulas which can only be done on the aggregated data; for that we cannot use this one. They are better suited on measure. So there is an option of column by example. You can create a new column by example. How that I'm going to give you one example now. There could be more uses; it has little complex data also; you can use it. What I'm going to do is I'm going to go to this text operation table, and in this text operation table, I'll go to a column—is my column key to—I'll right-click on that, and then there is option add column from example. Now I'll click on this option add column from examples, and here it is asking example. Let's say I put one one. What does it—it identify it that I am asking for text before delimiters, and based on that it is creating everything like text before delimiter. Let me go ahead and replace this with 333. Now what is happening? It now identified that I need text after delimiter. After which delimiter? It is identifying that I need it after the third delimiter, and that is why you are seeing in the second row it is using 33355. Now the same manner you go and type 222. What it will realize is that I need text between delimiter hyphen and hyphen, creating the next also. It is creating two and one to one, etc. In this manner, it is identifying that I need text between delimiter, and it is creating data like that. Now let me click on it. It would be added as a new column, and then you can look at the formula. This formula which has been—text between—has been used—hyphen and hyphen. So based on the example I try to do that operation, and based on that operation you will now get text before delimiter or text after delimiter, or there could be any other operations which has been identified we done here. These are the various ways in which you can create a new column in Power Query.
And once, once you are done with those columns from the home, you can go and click on close and apply or simply apply, and those columns would be added as part of your query which will be known as a table when we do the visualization part. The next operation which we wanted to learn is under the transform, and that operation is basically Group By. Now the group by operation is something which can create a group column. Basically, you have a complete table and group a data at a particular level. Use this group by, so basically summarized table or aggregated tables. If you, you can take help from group by. Now you have summarize in Dax which can do the similar job. There are other functions also like summarize columns; the job group by can also do the job. So now here in Power Query we are going to use group. So what I'm going to do is I'm going, I'm going to click on the sales table, and after that I'm going to click on group by. Once I click on the group by, it gives me two options: basic and advanced. In basic it is asking for one group by, and it is only asking one column. Now what I can do here is basically I can go to the advanced. In the advanced, I can add grouping of my own choice. So I can say, okay, I want to group this data, let's say, city, and then here in the count columns I can give a name of the column where the count has been written here. Then I can choose the operation: sum, average, median, min, max, count rows, count distinct rows, etc. We start with a simple example. We'll say we want to sum here, and what I would like to sum, I want to sum actually quantity here. Now here I'll say sum quantity. So this is the first kind of aggregation I want to create. Now I would like to add another, then I can go ahead and do it. Let's say I want average price. Now average price is not the best thing to have it here, but let's go ahead and do that. So we say average, and then we'll use. So you got an aggregated table now, or grouped by table now, which is now giving you city ID, sum of quantity, and average price. Now you can see the code here: table.Group by. At what it is doing, so city ID, it is grouped on that, and based on that we have list.sum which is used on the sum of quantity has been done, and average of price. I can click on the setting icon back again here, and I reached back to the setting again, and what I can do here is I can say add grouping, and in this add grouping I can, let's say, I add item ID. I want two group by—it's not one group; I want aggregated table which is based on city ID and item ID, and how I'm getting my data based on the city ID and item ID. In this manner, I can get it.
Now there is one more option which is there, and that would be helpful when you are going to do something like, you know, sub index or sub rank, that kind of operation that would be helpful, and for that what you have to do, let's go back to the setting again. Now here in the add grouping, let me remove this, and here I, instead of some operation, I'll say all rows. I can give it any name whichever I want. Let me call it all rows. Only when you go here, so city ID and item ID, the data is grouped, and what happens is it is going to have a table here. So now there is a table which is at the city ID and item ID level, and if you add a column here, let's say add index here in this table, and now we have to write down the formula to do that. It's not going to be that I simply go ahead and write it here. Add index. For that we have to use the M language, and using the M language we have to create a custom column, and there we, in this table itself, the table which is inside, we have to add an index column, and then you have to expand it back again. You can expand this table to get all the data, so you will expand, and then you'll get the complete sales table again, and then you will get the sub index. These kind of operations I have explained on the channel, so you can check that out. So in this manner you can group all the rows, and then you can do operations inside the group to data. So this is Group By for you. We, I have shown you a few options, but there are further more options which you can explore out to create aggregated or what we call summarized tables.
We will come across a scenario in Power Query where we would actually like to split a column. We have quite a few options to split a column. So we can split by delimiter, we can split by number of characters, we can split by position, lowercase, uppercase, digit, non-digit, non-digit and digit. Now I come up with this one data where I'm going to show you split by delimiter, but this data is really interesting because it's inquire double split, and you will not realize unless I do it. So for first of all, even before I use, do use first row as header, I need to split this data, okay, because name and ranks are two different columns, but I need to split this data, and how do I need to split it? I need to use under the Home tab, split column, and by delimiter, and space is my delimiter. It is automatically identified for each occurrence. In this case it is the leftmost occurrence, or that's the only occurrence, but you can decide if you have more than one occurrence: leftmost or rightmost or each occurrence, and then you can go to the advanced and decide whether you want columns or rows. In this case I want two columns, and that's correct; it has automatically identified that, but in case you want to check, you go ahead and check that out. In case of rows there's no limitation; it can split and give any number of rows, but definitely columns we have to specify. Let's press okay. Now we got the two columns. So now at this stage I can use first row as header. So the moment I do first row as header, you might have realized that this change type has changed the game for us. It actually has detected it as integer and removal of comma; that's what we don't want. So what we have to do is we have to go to this step, transform columns. Either we remove it or go and copy this type text, and in the rank also you use type text so that it remains as a text. Now it is a text. Now we can continue to use it. Now the rank column is something which we further wanted to split. We again go to split column, split by delimiter, and this time for each occurrence of the delimiter it has correctly detected that. In the advanced option I'm going to use rows, no more columns. I want multiple rows; for that I don't want columns this time, and in the rows it is not going to ask you how many rows, create that many rows which is required. Columns, the number is limited, and let's press on okay, and now the data is in the shape where we can use it for analysis. We've taken a case where we actually applied the same function twice in two different manners and get the data into the shape.
Now there are other ways to split also, and for that what I've done is I have this table, text operation, which you can use. I can show you some of those operations. So let's say you click on this key one, and you can say split by number of characters. I can split; I can get the year. First four are year. So by number of characters I can say once, as far left, I only want the first four characters, and rest I want into the second column. I don't want the repetition. Number of columns here is going to be two because I only want once. If it repeatedly, you need to tell how many columns. I only wanted once. I'll go ahead and press; I'll select once as far left as possible, the left-hand side, and multiple columns, and there are going to be two columns this time. So we are able to split and take out the year from this one. So this is split by number of characters. Now then there is a split by position. So split by position, position from 0 to 6. So Power Query starts with indexing, starts with zero, and then there are advanced options, columns or rows. You say okay, fine, 0 to 6, let's split that. So now you got another split based on that, and now this change data type on the first column we don't need actually; we need type text only, and because of that only it's not showing what value we actually got. This is the value we actually got. Then you have the uppercase, lowercase, and all those combinations. I will just show you one of them. So this is uppercase and lowercase. So you can go and split by column by lowercase to uppercase or uppercase to lowercase. So let's execute one of them, lowercase to uppercase. So when the things change from lowercase to uppercase, at that time we will split. So this was lowercase, and post that there was an uppercase, so it got split. There is uppercase, and after that there's a lowercase; there's nothing got split. This is—these were three were lowercase, and after that we got uppercase, so it got splitted. Similarly, digit and non-digit split, you can go ahead and use by non-digit and digit or by digit and non-digit. So let me use one of them. Let's use the second option, non-digit to digit. So you will only see split where first there was a non-digit and then digit. In this manner there are multiple things which we can do.
There are next set of operations. Basically, here we have lowercase, uppercase, capitalize the word, trim, clean, add prefix, add suffix. Now let me go to this table, and I'll go to column two, and let me try to—now to understand this format options. Now very easy to understand this lowercase and uppercase. You click on any, any of the column, you go here and say lowercase. I go to this column; everything is already in uppercase, so I can go here and say format, capitalize each word. So first letter would be capital. Now this is all in lower. If you see here, the, the column name, the first row is in the lowercase. I can go and click on the format and uppercase; it will do an uppercase. Now let me use first row as header and then do other operations. Now I can go here again, and under the transform format, I can use add prefix. It will add a prefix to the column. Let me add Hy, and in case I want to add a suffix, I can go to the format, and I can add a suffix also. Let me add @theate here, and it's not doing that operation on the null value, please remember that. Now what is this clean and trim? Trim you might have understood what, what is this clean? To understand the clean, let me go to the Home tab and create one enter data script, and here let me, and a shift enter, enter, enter a, space, b, space, c, d, d, d, enter, enter, enter, B, A, F, G. Now next one, I'll go here and space, space, space, a, space, space, space. Next one I'll space, space, space, b, c, v, V, C, and then here no space, b, and space, space, space, space, and let me say, let me rename this now, and edit. I got some data. You can see the values here, lying here and there. Now there is cleaning required. So first operation which I want to do here is basically I'll go to transform format and I'll do clean operation. The clean operation removes the non-printable characters, especially the, the enter. You can see now the data has come into the one row, but it has not removed the white spaces before and after it. They are still white spaces, like here if you go B and do have white spaces, okay, vbb do have white spaces in the beginning. Now I'll go on this column and I'll use the format trim operation, and once I do the trim it removes the white spaces from left and right, and I'll get the trimmed version of this one. Now you see there's no, nothing before and after; it's only B and only vbb. So these are the operations which allows you to improve the data quality. So the transformation, the data quality improvement, all these can be done. After that you have some operations to take out the date part and all those. If you go to this date time table and you want to take out the time only, it will give you time only. You want to take out the date only, you will get the date only. You want to take out part of the day, year, month, quarter, you will get those also. You can extract the date parts. Again, these kind of transformations you can do here. So these are the various kind of transformations you can do in Power Query. Once you are done with all your transformations, or maybe don't always wait for all the transformations to happen; you should keep on doing this in between; you should keep on applying the changes so that it doesn't take too much of time at the end to do it. But right now the time has come that I'll use close and apply, and once I do close and apply what it's going to do is all the tables is going to process again; the complete data will be loaded and processed again, and that is something which Power Query does. It basically actually goes to load the data model and go to process by each step by step and go to do it, and it has processed everything. Now the tables are now available for analysis, and if you go to the table view you will see the data into the final shape. So if you go to the pivot table or unpivot table, you will not see the data in the initial shape what you had; you see the data into the final shape. So Power Query helps us in creating transformed, cleaned data, data which can be used for data analysis.
So the next set of transformations which we actually wanted to learn is basically how to do multiple unpivot or double unpivot. Here what happens is you don't have a single column which is repeating; actually there are more than one column which are repeating. So let's say there is a set A1, A2, then there is a set B1, B2, then there is a set C1, C2, but that is the set which is repeating. It is not that I have A1, A2, A3, A4, A5, A6, and I just want I. In that scenario, how we are going to unpivot that is what we have to learn. So let's look into this example and see how can we do double unpivot or multiple unpivot. So let me showcase you my data which I'm planning to use for today, uh, so I have added this to the P data file, and I will be loading this file to the GitHub. So here as you can see I have item on my first column, and then I have state and value combination in the column. So I have state one, value one, state two, value two, state three, value three, state four, value four, state five, value five. This is the combination which I have. Now this is not a simple unpivot user case where I have the stage and I simply unpivot it and then I can use the data. So this requires a special treatment, or maybe I first unpivot the data and then pivot it. So let's go ahead and see how we convert this data into the best suitable data for data analytics or for Power BI. So I have already opened Power BI, and let me jump out of that, and I'll say get data, and inside the get data I'll bring my Excel sheet, and that Excel sheet is nothing other than pivot data, and you will be getting this on my GitHub account, and here you see that I got this unpivot pivot data. So just take this sheet, unpivot pivot data sheet, and that instead of loading, use transform data. Why would you use transform data? Because this data is not in a shape where we wanted to use. So why to load and then go to the transform data and do the transformation? Why don't we directly go to the transform data? So, so I'll click on the transform data at the bottom of the popup, and it will directly take me, me to Power Query. Let me bring in Power Query.
window on this screen so the power query window has opened, and now we have this data in front of us. So what action we wanted to do? So first of all, I'll select item and I'll go to transform. Inside the transform, I'll use unpivot columns, and I'll see unpivot other columns. Once I do, you can see I have state value in rows, but I don't want it like this. The best way is state as a column and value as a column. Now, to do that, I need to do a next step.
In the next step, I would use one more transformation, and the transformation which I plan to use is split column. Split column is again available under the transform tab. I want to use split by delimiter. In this case, you may have a little bit complex case, so you have to find out how you would plan to split that. And here I'll click on the advance option and I'll say I want to split into two columns; that's the most appropriate for this data. For each occurrence, yes, or sometimes you may have to use the leftmost delimiter, so the first delimiter which it gets on that, and you have to say okay. Now what you see here is state number has been separated out. Now you can give it as a separate name there, but that we will do later. But you can click on now attribute and value, and you can go to what column again under the transform data, and which column is the value column? Yes, value column is the value column. Advance option: what I wanted to do is I'll say don't aggregate, but I would prefer to do max if required. So you can take a count here, and once you load this data, instead of list count, you click on the bar where we are seeing this formula, you send this Max, and now you can see State and value. We could have used to aggregate, but in case don't aggregate doesn't work, you can use max like this. So I got State, I got value, and this could be state number or type; let me call it type. Now this data is in a proper shape for analysis. So this is how you deal with the data where you think it requires multiple unpivot.
Now what we would like to do here is we like to understand how can we do a cross join in power query. Now you have seen an example where we have actually done a cross join in DAX. Now how do we do a cross join in our query? Because there's no function cross join. If you remember, we had merge, which can do different kinds of joins like Left, Right, full, and full is not cross join, and then we have AND joins also, but how do we do cross join? Cross join means every row of a table will get populated against every row of another table. One has three rows and table two has three rows; end up getting nine rows. So this is what the cross join is, and we would like to understand how can we do that in our query. So let me take you through Power BI and let me explain you the function, the cross join function which is there in the DAX, and then the question is how do we do that in power query. So let me do one thing: basically in Power BI Desktop, I'm going to use enter data, which is under the Home tab, and I'm going to create two tables. In the table one, let me have that say number; I'm going to have some numbers, let's say 1, 2, 3, and 4, and let me call it D1, the table D1. I'm renaming it, and I'm going to say load a very simple table. Once this table gets loaded, we will load another table. So now let me add another table. Now the table which I'm going to add is basically having the, let's say text. So let me call it value, and let me add value, let's say a, b, and c, only three values, and let me call this table as D2, and let me load very simple stuff, two tables having one column. Now I go to the table view, and I'll show you these tables. So D1 as 1, 2, 3, 4; D2 as a, b, c. Now how do we do a cross join? So in the DAX, in we go to the table tools. When we click on any of the table, we'll get the table tool, and in the table tool, you have new table. Click on the new table and say cross; the name left-hand side is the name, and then we have function cross join. We can give tables, so I give D1, comma D2, two tables, and I just press enter. Now what you see is 1, 2, 3, 4, A, A, A, A, 1, 2, 3, 4, b, b, b, b, 1, 2, 3, 4, c, c, c, c. Now I want the same thing in power query; how do I do that? So I go to my report view, or I could have done from there also, and I go to transform data, which is in the middle of the Home tab, and there I have another option transform data, which will take me to Power Query. Let me bring in the power query window here. Now how do I do it in power query? So if you remember, we have something known as merge queries under the Home tab of power query on the right, but here when you go to the merge queries, you don't have any option for Cartesian, and even if you do full outer join, it's not going to serve a purpose, especially there is no join column here. So how do I do that? But to do that, what I can do is I can take any one of these tables and go ahead and create a new column, add column, I call it custom column, and let me call it tab two, and let me simply give here D2. D2 is a table, so it starts showing me the table. My, once I get a table in a column, it starts giving me an expand icon. I'll expand this, and it asks what all columns I say I will say value column I need, and I'll uncheck this use original column name as prefix. Then we press okay. Now, as you can see, the moment I expand it, it gives me A, B, C, A, B, C, A, B, C, because I done it with D1, that's how it's going to happen. So for Value one, A, B, C, or then if you see for a, it is 1, 2, 3, and 4. Anyways, I could have done the same thing in D2; it would have given me a, 1, 2, 3, 4, b, 1, 2, 3, 4, c, 1, 2, 3, 4. So this is how you do a Cartesian product, cross join in power query. So when I was trying to save this, it gave me some error. So what I've done is basically I changed it to Value one. The reason it is giving error because D1 and D2 we are again using in the cross join, they, the value column and so because of that it was giving errors in power query. It is possible to do much more complex operations than what we have done so far. Right now what we are doing is we are combining certain sets of operations and try to achieve the complex operation, but once we are able to understand all the complex M functions, we can do much more powerful operations than what we have done so far. So let's understand the basics of M for now. M is a case-sensitive language. What do you mean by case-sensitive language? In case sensitivity, what happens? Let's say you write down sales, and in one of the sales you write down S capital; that is different from the sales where s is small. M is case-sensitive, so your column names with the title case or small case or upper case are different from each other. Same is true for the tables. So when you are using them into your formulas or into your calculation, you need to take care of them. What is the process of working on M language? What is the syntax? Every language has a syntax. Let's say you are working with C or Java. In case of C, you create a main function where you write down the code. In case of Java, you start with a class and then you have the main function. So every language has a particular kind of syntax. So what is the syntax we have for M? To create an M query in the query editor, you have to follow these basic processes: First is create a series of query formula steps that start with let statement. So let is the first statement. Each step is defined by a variable name. So every step you will have a variable name, and an L variable can be included by space using hash character as HH double codes step name. So basically what happens if you don't have the space in your variable names, it could be simply a name, but if you want to give a space, then you have to use hash hash and in the double codes you to give the name with the space. So let's say my name of the step is rename columns, so I'll give hash double code rename space columns. This is how I will give the variable name if it requires space. A formula step can be a custom formula. Please note that the power query formula language is case-sensitive. So power query formula language is case-sensitive; it means if you write down let's say rename column r capital c capital is different from R small and C small. In case of M query, each formula steps build upon a previous step by referring the step by its variable name. So what happens when you look at the code which is automatically generated by power query, you will find that each step is referring to the previous step. That is not necessary when we start the coding. I'll showcase you that it is not necessary you refer it to the immediate step; you can do some calculation and post that you can also refer it, but typically what happens in power query when we are autogenerating, most of the steps are generating tables, and the table in the step one is getting referred by the step two and so on. Finally what we do is we output a query formula step using the in statement. So basically you will give a variable name finally after the in; generally the last step in used in the final data set result. So what happens, whatever is the last step you actually try to return the result of the last step. However, it is not compulsory, but in a logical flow that would actually happen.
So let's take an example code. In this example code, you can see the code starts with the let statement, and in the next line you have variable name equals to expression; means you are assigning the expression to the variable name. In the next one you have hash variable name equal to expression two, which you are assigning to a variable name which is basically having the space, and finally you end up returning the variable name here. See, we are not returning the last step; we are returning a step before. So that is also possible. Just like every other language, we have the data types here; we call it primitive values. A primitive value is a single-part value such as number, logical, text, or null. A null can be used to indicate the absence of any data; if the value is not present, that's what we call null. So let's say binary is something like 0 0 and something like that. Date is your all your dates, date and time, date along with the time, date time zone; it will also include date time as well as time zone. Duration: now duration is not same as time; duration will have Day, hours, minutes, and seconds. Then you have logical, which is true and false. Null means you have a null value. Number: you can have 1, 2, 3, 4, or you can have decimal numbers. Text: you can have ABC or any kind of text which you want. Text can have numbers also, and then time, and time is different from dur; time will have only time for 24 hours; it will not have the day component which duration has. In power query, we can use functions. A function is a value that when invoked with argument produces a new value; means you have to give the argument, and when you invoke it, it will produce a new value. Functions are written by listing the functions parameter in the parenthesis. So in the parenthesis you have to give the parameters followed by goes to symbol; means this equal to an arrow is known as goes to symbol, followed by the expression defining the function. For example, to create a function called my function that has two parameters and perform a calculation on parameter 1 plus parameter 2. So this is an example which has been given. So first statement is let my function equals to the parameters parameter 1 and parameter 2; you can have more than two parameters; that's not a limitation; that's just an example, and then the goes by or the arrow symbol, then you have in the parenthesis parameter 1 plus parameter 2; means we are first adding them and then dividing it by two. So this function is going to return the combined half value if when we invoke it, and then in my function you are returning the value which is finally returned by my function. We have some structured data values that include list, record, table, and some additional structure. Now list is something which is like a column; so basically a set of values is known as list. So a table column is also considered as a list. Record is a record where we have a column name and a value, column name and a value; it's basically like a row. So you can consider a table row as a record, and a table column, fully qualified table column name is considered as a list. Now there are differences; we cannot always use the same term, but this is just an example. What we will do when we actually go ahead and do the coding, we will use the table column as a list also, and we'll do the list operation on that. So these are the few data types which are really important, and there are tons of operations around list, record, text, number, and dates, and if you are able to practice those functions, you will be able to solve many complex logics, and most of these functions are already discussed on my YouTube channel, so you can take advantage of that. In this series and video, we are going to consider some of them so that you can create a foundation for using other functions. Let's jump on to the new Power BI file. I already opened a new Power BI file, and how do we reach power query? So we click on the transform data, and under that we again have the transform data, and from there we will reach the power query. Once we open the power query, you will find nothing is there; it is empty. What we have to do is we have to add a new source. For that we are going to use the new source option under the Home tab, and from there we will go to blank query and add a blank query. What happens when you create the blank query? It creates it with default steps, and we have to modify those default steps. How do we reach there? Reach either you can use right-click Advance editor, or there is an advance editor option in the Home tab also. I will use the right-click advance editor. Let me open that. Now here in the source, let's say I can write down an integer one. Then we click on done. Now you can see it is returning one. Every time you return return anything other than table, it gives you an option to convert that to a table. If it is not a list, it can give you convert to a list or to a table, but the list it will only give you convert to a table. It is returning right now one, which is of number data type. Every time you do an operation based on that operation's return type, it is going to return that particular data type. I can go here Advance editor again, and I can make it let's say double codes a b c, and if I return now, now it is returning a string, and the moment I return the string, I have different options like format; it identifies the written type, and based on that it gives the different options to us. Same way we can perform some operations. Right-click, go to advance editor, and this, and it is not necessary the name needs to be source. So let's create a variable a = to 1, comma, next line b = to 2, comma, c = to a + b, and let's return return c. Let me click on done to close the Advance editor and get the results. Just like any other programming language, I'm getting the results of c which is a + b equals to 3. Same way again we can go ahead, right-click, advance editor, and we can modify it. Let's say to multiply this, but for multiplication let's take a little bit different numbers. Let's take a is equal to 3, b equal to a multiply by b, and let's click on the done, and we are getting the expected result 6. It is not that we can do the operations on number only; we can do it on text also. So let's go back again using the Advance editor. Let's change these two strings. Now hey, I'm going to give in double codes Microsoft without space, second one we'll call this power BI, return on. Let's try to add them. So a ampersand b, let's return p, so c is appending Microsoft and power BI in the space. Click on the done and let's check the result. The result is Microsoft powerbi, and it is a text, and we are getting option to edit the text. In this manner, you can do some basic operations. So let's name this right now as q1, query one. I can double click or rename, right-click or rename; these are various options are there, and as you see every step has been given here, applied steps, and these steps can be deleted or added, between steps can be added as per right. Let's understand in more detail what all steps we have created. So let's go back to the Advance editor again, and in advanced editor you can see in the step one we have assigned a value, step two we assigned a value, and step three we appended this value, and finally in the end we have given back that value. So how we have done it: let variable, and the data variable, and the data variable, and the operation, and then finally in the in we have the variable which we plan to return. So this is what we have done: let variable, variable operation, and R, and then finally press done. Now let's go ahead and try more stuff. So what I would like to now here is let me try to create a list. So for list, let's start again by creating a new query. We go to the open tab, we'll take a blank query, right-click and want editor. Let me create a list. List is something where we give data into the angular brackets. Now it's a list of mix 1, 2, 3, a; that's a mixed list I wanted to create. I to return the same, but you can see list of mix which have created. Create one more list. Go back to the tab, new source, blank query, again right-click, advance, and let's create list of numbers. Source equals to list of numbers. How do we give a list in the angular bracket? If you give the comma-separated value, that is list. If you are giving numbers, read of double code. If you want to give the text, then you have to give them in double code. We creating a list, angular brackets; when we use it, creates a list. Press on done, and let's return this. We got a list 1, 2, 3 again. Now this time, if you look at here, you have an option as it is a list; there is only one option to table; there is no option to list here. Let's take one more example. This time we are going to create a list of lists. Again, new source, blank query, right-click, Advance editor, and here inside the angular bracket what I'm doing is angular bracket 1, 2, 3, angular bracket 4, 5, 6, and then again angular bracket; list of list I'm creating. Click on done, and you can see there's a list. If you click on that, look at below; you will get the data, and this do allow you to expand. So once you convert it into a table, this will allow you to expand the list and further do more operations. Let's create list of text also. New source, blank query, right-click, Advance editor, in the envelope brackets a, b, c, e, e, f, i, and let's click on. Now we got a list of text. Now we would like to create something which is a little bit more interesting; we want to create a how do we create a record? Let's go to the Home tab, new source, blank.
Query: Let's right-click and then enter. Now, in the square bracket, we to write down the record. The square bracket: you can write down the record, and the record, what you name of the column and the value, name of the column and the value, name of the and the value. This is how you write down in the square bracket. Now, there is no currently here. Give square bracket. Click on Done. How you going to record? Now record. When we convert to a table, it—let's take example here—actually converts it into like four records. We have to actually ask whose it now. Who knows it? And this is the step which is automatically added. Let's look at here, Advanced Editor, and now you will understand that you know how the previous step is referred. This was the previous step, and when we convert it to the table here, if you look, Record to Table, this step has been referred here. We have referring source is referring to the source of the last step, and then in is referring to the last step name. This is how we refer steps in subsequent steps.
Now, let's take one more example, and this time what we are going to create is a list of records. New source, blank query. Right-click, Advanced Editor here. Now, square ones are the records, and comma-separated list of Records inside the angular bracket, creating the list. Click on Done. You got records. You can see your records here. Let's convert it into two tables. Okay, you select the option, then you can see you got two records, and now you can expand the record, expand the record, and you will get a table like this. In this manner, these are the steps. So now, remember these functions are automatically added by menu. Let me show you those into the Advanced Editor, but you can also manually write down these steps if you know the function like Table from List, Table from Expand Record. You will be able to write down all these, and in the beginner tutorial series, I covered most of these. Then go ahead and try that out. Now, everywhere you see the reference of the last step returning the last step in this manner, the entire flow is happening.
Now, let's take an example: how do we create a table? Now, there are multiple ways to create a table: Table from Record, Table from List. But let's take one of the example when you wanted to create a table, and the function which we are going to use is Hash Table. The new source, blank query. Right-click, Advance Editor, and here we are going to write down Hash Table. Now, after the Hash Table, what is the syntax? You need to give first a list, a list which will contain the column names, and then you get need give a list of lists which will contain your each row. The list, then list of list. The two arguments: one is list and then list of list. These are the two arguments Hash Table requires. Putting this Hash Table into the SCE and we are returning. Click on Done, and you will get your table. And you got a table directly. We got a table. Let's try one more example. This example again we are going to use Hash Table, but with a little bit different. Again, blank query, new source, blank query. Right-click, Editor. Here, in the Hash Table, first we say type Table, then we give a record. The record contains the data type also. Now, here previously we have not mentioned the data type. Here we are mentioning: Order ID is number, Customer ID is number, Item is text, Price is number, and then giving list of list. So the only thing is the first argument we have changed, and the first argument we giving type Table. We are telling the record where we are telling the column name and the data type, and then we are giving list of list. Let's click on that. Again, you got the table. Let me add one more query here.
Land query. In this query, let's take an example of list of Records. So new source, blank query. Right-click, Advanced Editor. The Source equals to list, and inside the list we have records. So list of Records what we are trying, and inside the record as usual, the column name, the value, column name and value. Let's click on Done. We got list of Records. We can convert this into a table. We'll expand the records and can get our full table. Now we will look at an example where we wanted to create a table from Recon. So let's create one more query. Home, new sources, L query. Right-click, Advanced Editor. And so here what we are doing is in the source we are getting Table from Records. This is the function, and inside this function we are giving a list of Records. That's what we have to give. Every list has records. Every record has columns and the values, different data types and different names can be there, then another record, then one more record. We can have as many records as we want. Then you click on that. Now you have learned how can we create numbers, text, list, records, table, Table from Records, Table from List, and so many things. Now we have to learn a few more things. For a few things, you cannot simply write down a value. Let—let's take an example of date. How are you going to write down dates? Let's add a blank query and right-click, Advanced Editor. For some of those, we have shortcut hash functions. Like for date, we have Hash Date. You seen Hash Table, we have Hash Date here. 2024, 01, 01. Click on Done. You got a date. Similarly, right-click, Advanced Editor. You can Date Time. Are you going to have six arguments? 14 Z. Click on Done. You have Date Time, and you can see, check the data type, it is showing now Date Time, and then it is giving option for date separation, time separation.
Now, let's create duration also. New query. Right-click, Advanced Editor. As Duration, and these are all small. Typically it is case-sensitive, and you will always find the functions names are in title case, like Table.DoRecord and all those, but here is all small when it is coming with Hash, Hash Table, Hash Date, Hash Date Time, Hash Duration, and Duration. You can give first day, then hour, minutes, seconds. Click on Done, and you got a duration. Now you before to create a list of duration or list of time, you can right-click, do Advanced Editor. If angular bracket, and in the angular bracket, one of that. Click on Done. Get the list of duration. We can create a table from it. These are some of the basic functions and operations you must remember. Now, before I tell you a little bit more about some of the functions which could be really useful, I would like to import one file again and show you what are the steps which file creates, and again for that I'm going to take out our favorite file, T data used in videos. By bringing this file, we would like to understand what all steps is going to create. I'll bring in the sales data US video again. So new source, B, give the URL, click on Okay, and we don't need to bring in all the sheet. Can bring in one sheet. Let's bring in Customer. Click on Okay, and there was no load button or transform button this time because we are in Power Query, so we are going to each here only. We are not interested in what is coming here on the table view. We are more interested in right-click, Advanced Editor, and what is happening here is basically there is a let. This is the first step where we are getting the Excel sheet. Now, from the Excel sheet, these ports we are getting the data of sheet, Customer sheet, item, Customer kinda sheet data. So we are getting the sheets data. After that, Promote Header, and look for what Promote Header is referring. It is referring to the Customer sheet. What Customer sheet is referring is referring to for the function which has been used on for. Then we have Change Type. Change Type, if you see, it is referring to the promoted address which is the last, and finally the page type is the one which is getting R. In this matter, what is happening is basically each step you getting a data, and the next step is that transformation to the next level. What we think in such cases that every time it is referring to the last step, but if that is not completely true. Sometime it may happen just like we have done in our older example that it can refer to the previous step or previous to previous step. We might have a couple of steps, and after that the output will be used in another step. So those combinations are also possible. Most of the time what happens it is T table at the each step. So what we think is it is a table in the first step. It is a table which is carrying on the next step. Next step it is a table, and then further more table. Table is referring to the last step which is table and again giving us table, but that is not completely true. Just like any other programming language, we can have steps which can have different kind of variables, and those can be combined to create a result T. And because finally we want a table for analysis, that is why most of our Power Query final output would be a table.
Now, there are functions where we will be able to loop the function, funs which will allow you to loop through each row of the table. There are functions which allow you to loop through the each element of the list, and using those functions you will be able to create loops or able to process row by row data. So just like any other programming language, we have a lot of things which we can use here, but in this series and video we'll might not be able to cover everything, but we'll try to give you an overview which would help you to use other functions. Let's also understand what are Power Query functions. So to understand that, let's go back to the file which we are right now already in progress, and in this file what I'm going to do here is I'm going to go to the Home tab, New Query, blank query, and inside that blank query, let me create a function. Let me do go ahead and do right-click, Advanced Editor. You want to create a simple function, function which is going to do is My Function, or I can give it as any name. I don't need Source in that case. I need to return this My Function. So let me call it Addition, FN Addition function. What Addition function equals to the parameters X and Y, and what the operation they should do? X and Y are actually summing up. This can do any other complex operation. Now let's return, return this Addition function. Done. Let's rename this query also. Now, if you want to test, you can give here, let's say three and four, and those invoke, and it will give you answer as s, and it has actually created a new query. If you see when you use invoke, right-click, advance and return, it has actually created Force Addition function. This is the query name. Please remember if your query name is different from your function name, you have to use the query name, query name, not the function name. So whenever you're creating the function, make sure your function name and query name is same so that you don't get confused with two. So Addition function T comma 4 and integ instead of I go ahead and doing that, it has created that. So in could have done that bland query, tested it, or you can use this function now in any other query which you are doing. So in this, this manner you can create functions which you can actually use in your other operations. So let's take one more example of the function. Go to BL tab, Force blank query, and in this blank query, Advanced Editor, let's use Source as a function equals to a comma B goes to a m per p m per B. So if you remember what we have written in the past, and let's call this aend function, aend a Capital fnend function. Let's create an append function, c contr v WR append in the in. Now we got an append function. We name this query as a pan function. Let's give a as Microsoft, b as power B. Let's use it, the Microsoft Power BI. It has it has created a query for us and which is giving us the result in this manner. You can create Power Query function which can do some complex transformation and or solve some kind of operation, and you can you call those functions into other queries. This is a brief overview of Power Query functions. Power Query offers you tons of functions which you can use to improve your transformation. These functions include list function, table function, record function, text function, number function, etc. Now it is not possible to cover all of these functions in this series and video. So what I'm I'm going to do is I'm going to cover some of these functions uh in this particular video. I will cover some basic list functions which can help you understand how to perform list operation, and based on that you can go ahead and perform more operations by looking at the documentation of different functions. Most of these functions are covered on my channels in the beginner tutorial series. You can go ahead and learn from there. Every function is fit for a purpose, and if you are able to learn most of these functions, you will be able to perform many transformations with ease. Let's jump back to the Power BI, and the first thing which I would like to do here in Power BI file is I would like to click on Close and Apply, and once that is done means the data is loaded, I will save this file, and once this file is saved, we will go back to the Power Query and start doing some list Transformations. Data loading is done. Now time has come that we save this file. Let me click on the save icon on the left top, give this file name as N2 n14, and click on the save button to save this file. So let's go back to the Power Query using Transform Data, Transform Data, and here now we will try to learn some list operations. Home tab, New Source, blank query. Right-click on the new query, open Advanced Editor, and in Advanced Editor we are going to create a list inside the angular brackets. Let me create a list of numbers by giving 1, 2, 5, 6, 7, 3, and 4. Don't want to give it in the order so that later on I can showcase you list.sort. Let's click on Done. I got a list. What I can do is I can open this Advanced Editor again here on this step or on the next step. I can do this list dot. There are so many operations. This dot I have sum, I have count, I have min, max, all those functions are there. Let me use list.sort to sort this list first. Let's try list.sort, and in this function I have to give list only one argument it takes. That's a list. List is something which we have in the envelope bracket. Let's click on Done, and as you can see the list is sorted in a proper order. Now, instead of going back here, I'm seeing the list. I can use list.sum, and you will see I get a sum. Now it is wring a number; it's not no more a list. Similarly, I can try list.Max here will give me maximum of the is 7even. In Max you Dy Min list.Min, Min function you come here, the list.Min, it is list IFA as any comparison criteria, all those arguments you can give. We will get the minimum value from the list, that is one. So we are getting one. So if we have something known as count also, we can use count, list.count. Let's see what all argumented need, the list argument, and it will return return us seven. Now let's go ahead and add one more list item so that it gives us eight, and we are able to differentiate between the Max and the count. Now we are interested in a couple more operations, and those operations are one which will allow us to loop through the list and do additional operations. Let we add a blank query for that. New source, blank query. Right-click, open Advanced Editor, and we are now going to learn the function list.number. list.number needs three arguments. First argument is basically start, so from where you want to start. So I want to start with one. How many numbers you need? 100, and increment by which is I want one in this case. So it will give me 1 to 100 numbers. So this is a continuous number series. In case you want an odd number series, what you can do is you can increment by two, and it will become an odd number series, and it is going to give you 100 numbers. It is Count, total numbers you need, not like your generate Series where 1 to 100 is start and end limit. This is not the limit; this is the count. Now, in case you want an even number series, then you can start with two. For odd number series, you can start with one. Let's start with the first argument, two comma 100, 100 numbers I need, and then increment by two, and this will give me now an even number series, a list of 100 even num starting from two. There are more such functions. So let's go to the new source, blank query. Right-click, Advanced Editor, and here we are going to now use list.dates. It can generate a list of dates that will help us to create a calendar, but we do have the functions like list.datetime, we do have list.duration that can give us continuous duration, but at this time we will focus at list.dates. So list.dates would require three arguments. The first argument is date. For that I'm going to use shortcut Hash Date. It again required three arguments here which is 2022, month 01, and day 01, comma, the count of dates I need, 365 dates, almost for an Year, and that the duration again I'll use the shortcut function hex duration, and in the duration the first argument is day, and because I require a date table I'll use one, then hour, minutes, and second I'm going to use zero, and I'll click on Done, and this will give me a series of dates which will help me in creating the date table. So I am now getting continuous dates. To create a date table, we also have another powerful function, list.generate, which we can also use. So let's start again with a new query. Home tab, New Source, blank query. Right-click, Advanced Editor, and here we are going to use the powerful function list.generate. list.generate and it requires three arguments, and all three are functions: the initial function, the condition function, and the next function. So what is the first argument? The first argument is a function without any parameters, goes by means the arrow, and the value which I want to give to this function is a static value of t to start with. The next argument is condition, and the condition is each_ greater than zero. Here generate is creating a loop, and each is giving us each value to compare and take a decision. Third argument is increased, and how we will give it? Each_ minus one means from each row supp the one one value it will give us, reducing list. So generate function generates a list of values using provided function. The initial function generates the starting candidate value which is then tested by the condition. If the candidate value is approved, then it's returned as a part of the resulting list, and the next candidate value is generating by passing the newly approved value to the next. So we have an initial value of 10, tested every time for greater than zero, and every value is reduced for minus 1 to generate a list of values. And let me click on Done, and now we are getting values from 10 to 1, decreasing by one in each row. If you want an increasing number list, you can start with one and say _ less than 100, and then we can change the increment by + one, each_ + one. Here the _ represent the value in each time we are calculating it. Each time we are looping that value is the _ value where we are adding the one. We got a list of numbers using list.generate function this time. So we have understood a few list functions. We have tons of list functions that include list.sum, mean, Max, count, contains, contains all, distinct, date, date time, duration, intersect, distinct, last, last 10, matches all. There are so many functions which we can discuss, but it is not possible to discuss all of them as part of this video or series. What you can do is you can watch the beginner tutorial series on the channel and can take advantage of all of these functions discussed there. There are other Power Query functions which deal with date, number, text, table, record, etc. Let us learn some text functions in Power Query, and to do that let's go back to the the same file again, the file N2 n14, and I have already opened.
Power Query: Creating a Date Table
In that file, we have created the list of dates using the list functions, which I've explained in the previous video already. What I'm going to do is, first of all, let me call it as "Dates List", and now let me convert this into a table. To convert this into a table will automatically add a step, and that step is nothing but "List from Table". This is the table function which uses source, which is basically a list splitter. Split by nothing, null, null, extra values, or error—these are the things which has to be provided. "Table from List" Power Query function helps us to convert a list into a table with required arguments. This list has been converted into a table. Let me rename this as "Dat". Also, let me change the data type by clicking on the left top of the column where "ABC" is written and change it to "Date". You can observe that the data type is "Date" now.
To start this journey, first of all, I'll convert this date into text, and we will use some text part functions to get different parts of the date. We have text functions which are text.start, text.middle, and text.end to take out different parts from a text. So let's start this journey by creating a new column using the custom column. So add column, new custom column, and let's create a "Text Date" column. To achieve this, we are going to use the function date.totext. So that function will convert the date into a text date, and the first argument which we supposed to give is the date column, comma, and the second argument is the format which we are going to give into the double quotes: yyyy (four times), MM (that would be in capital), and dd (in small). So this is the format we supposed to give. Our query is case-sensitive, so check out the documentation when to give a capital letter and when to give small letters in the format. Click on "OK" and check the data. So let's scroll down into the data and check it out. Let's scroll down to another month and check. Yes, this format is correct. So the format which we have used here is 4y (in small), 2M (in capital), and 2d (in small), and this has worked for this use case. The data type is "Any" as of now, and we need to change it. Now to change what I'm going to do is this "Add Column" function itself. I will go and give the third argument, so comma, the third argument needs a type, so here I'm going to give "Text.Type". So it's going to give the text data type, and once I give this argument, I will press Enter. This argument has corrected the data type. In the same manner, you can give "Number.Type" or "Int64.Type" to correct your data type as per the need for the required column.
We will start the process of converting this text into a date. For that, we will require a date function, and we will also require the text function to take out the start, middle, and the end part. We might also require conversion of text into integer. Click on "Add Column", "Custom Column" to create a new column, and I'm going to call this new column as "Date1". So let me replace the name with "Date1". In this one, I'll use the #date function first of all, which takes three arguments: year, month, and day. The first argument is here; for that, we need the first four characters. So for that, we are going to use the function "Text.Start". Now the first argument in this function, we need to give the "Text Date", so we will give "Text Date" as the first argument, comma; we need four characters, so we need to give four, and then we can close the parenthesis. So the next argument which we are going to use is "Text.Middle", and in the "Text.Middle", we need three arguments. So the first argument which we need to use in the "Text.Middle" is the "Text Date". Then we need the starting point, which is five in our case (the four characters of year and hyphen), and then the next character to start (because it starts from zero), so five. We need two characters of month, so two, close parenthesis, comma; need day in the last argument. So the function we are going to use here is "Text.End" to get the last two characters in the string. So the first argument here is going to be the "Text Date", and then we need two characters from the end, so we are going to give two, and then we will close the parenthesis, and then we got the date. Now we can click on "OK" to check it out. It is giving an error. The reason it is giving an error is because we need the three arguments as whole numbers or integers, but all the three arguments what we have given are text. So what we need to do is we need to convert this text into the number—the start, the middle, and the end. For that, we have the function "Number.FromText". Let's use the function "Number.FromText" on all the three arguments. I have knowingly given a space after the parenthesis because when we try to select the function, sometimes it replaces the existing function if you don't give the space. So this function "Number.FromText", we need to use on all the three arguments to convert them into the number so that the date function can use them. Once we completed our formula, you can see that we got all the dates correctly. Now the dates are displayed. Currently, my format is the US date formats, and based on that format, the dates are displayed. In case you are using the UK or Australia format, you will get the date into that default format.
These are some of the basic text functions which we have used here, but there are a lot many text functions, and I have covered quite a few of them on my channel in different videos which you can go ahead and explore. Some of the functions which were available as part of the menus are also available as functions so that we can do complex transformation by using those individual functions, and we will continue to explore these functions in different different videos. We have created a date table index in the past. Now time has come that we create the date table in Power Query. We have learned some of the Power Query functions and time to learn some new functions to create the date table. Our DAX Power Query table is pretty comprehensive, and we can create such a comprehensive table using Power Query also, or even more comprehensive by using additional functions. So let's begin our journey of creating the date table in Power Query.
I'm going to jump on the existing file which we have created, and to N and 14, I'll go to the "Transform Data", which will open the Power Query module. I would like to add a new query, so I'll go to the "Home" tab, "New Query", "Blank Query", and this will add a blank query. I would now like to rename this, so right-click and rename is one option; double-click and you will go inside the query, and you can rename it. I will rename it as "Date Table" and press Enter, and let me open the advanced editor. Now, first of all, we will define two dates because we wanted to have a calendar between two dates, but the function which we plan to use, "List.Dates", does not take two date arguments; it takes a date argument and the number of days. So we need to learn how do we take the difference between two dates to provide to this particular function. So first let's start with the "Start Date". "Start Date" as a variable equals to a value. This is how you define a variable here. So "Start Date" equals to #date. The #date function requires three arguments: the first argument it requires is year, second is month, third is day. So the first argument I'm going to give is 2018, which is the year; 01 is the month; 01 is the day; close parenthesis, give a comma, and go to the next line to start a new variable. Now let's define "_End_Date" equals to #date. 2022 is the year, comma, 12 month, comma, 31 as a day. The next step is to get the list of dates. For that, we are going to use the "List.Dates" function. So let's define variable "_Date" equals to "List.Dates". Now the "List.Dates" function requires three arguments: the first argument is the start date, the second argument is "Count" (means number of days), the third argument is "Step" (means how many days it should jump between each list items). I am going to give the "Start Date" as the first argument which we have created some time back. So the first argument is "_Start_Date". For the second argument, we need the number of days, the count, and that can come from the difference of "End Date" minus "Start Date", which is pretty easy in Power Query, but that's returns as duration, not date. So let me define a new variable "_Diff", which will contain the difference of these two dates. So "_Diff" equals to "_End_Date" minus "_Start_Date", and this will return me the difference between two days in duration. Now I need to use a function "Duration.Days" to get the days out of this duration. Now I will get the number of days between these two dates using this function, plus one to cover up the subtraction difference to get the exact days back to the list of dates. Let's give the second argument, which is "_Diff" (number of days or count). The third argument is the step which is required in duration, so we are going to use a function #duration, which can provide us the duration. So function #duration requires four arguments: the first argument is day, and that is what is most important for us, so one day, 0 hours, 0 minutes, and 0 seconds, and now we are done. This is the last step in our course, so copy this and return it using the "in". So "_Date" is going to return the list of dates. Let's click on "Create" to complete this query. Now we got the required list of date. We can scroll and check it out; all the dates are available here. We can sort it descending to see what is the end date which we wanted, but every time we do anything, it adds a step. As we don't need this step app, I'm going to remove it by pressing on the cross button. Let's convert this list into the table. So right-click, "Advanced Editor", and then we will enter here "_Date_Table" was the last step; it was giving an error, means the last step was not closed. So now let's use the "Table from List" function. What I've done is actually copied it from the last one, so "Table from List". Now the last step is "Dates List of Dates", which I need—list of dates; then "Splitter.SplitByNothing", that's because we don't want to split; null, null, extra values, error; there the argument which needs the main argument is list, and then "Splitter.SplitByNothing". There is a way we need to split this list; we want to give that we can use, but here we don't want to by anything; we are giving other two arguments; we are giving nothing, and then extra value, error, and let's return this. Now if I still return the date, it will not convert it into a table; let "Date Table"; click on "Create". A few things we have to change. So first of all, using the left top corner, change the data type to "Date". So the data type of this column should be "Date". So let's convert that into "Date". Now double-click inside the column to rename it; rename it to "Date". "Date Table" required many columns which I'm going to add now one by one. To do that, we can use the "Add Column" tab. Inside the "Add Column", we have "Custom Column" that I'm going to use again and again to add new columns whenever I need a new column in this table. So let me add the first column by clicking on "Custom Column". The column I want to add is "Start of Month", means I want to get the first date of the month. We have a function available for that; the function is "Date.StartOfMonth", and this function "StartOfMonth" requires only one argument, that is "Date", and based on that it can give us the start date of the month. One argument is needed to give us the start of the month or the first date of the month. Let's press "OK", so we got a new column "Start of Month", which is giving us the first date of the month. We need to correct the data type of this, so we can add the third argument to the "Add Column", and there we can use "Date.Type". It requires a type to convert it into the correct type, and let's press Enter to get the correct data type. Let's quickly add one more column, and the column this time I would like to add is "End of Month". I want to get the last date of the month. Very simple function: "Date.EndOfMonth", which requires only one argument, that is "Date", which I'm going to provide it; close the parenthesis, and now I can get the "End of Month" date. Let's press "OK" to get it. The data type of this column is also not correct, and as you know, we need to add the third argument. Let me copy it from the previous column and add it as the third argument, comma "Date.Type", to get the correct data type. So the data type is corrected. Time has come to add more columns. Add the new column, and the new column is "Start of Quarter", means the first date of the quarter is what we need here. So the function we are going to use is "Date.StartOfQuarter". Very simple function; it also requires only one argument, and that argument is "Date", so we'll provide the "Date" argument, close the parenthesis, and this function will going to give us the start of the quarter date. Click on "Done" to get the new column. The new column is the start of the quarter date, and now I would like to add one more column, and the column will be "End of Quarter", means the last date of the quarter. Let's quickly add a new column, "End of Qtr", means "End of Quarter", and we are going to use a function "Date.EndOfQuarter". Again, this function requires only one argument, and that argument is "Date", so let's provide the "Date" argument and click on "OK" to get the new column. So now let's look at the data; look at the very first row; we are getting the start of the month and end of the month, start of the quarter and end of the quarter for that particular given date. We scroll down, go to another month; we are getting different start of the month and end of the month, but as of now we are getting the same quarter start date and same quarter end date. If we scroll down further till the April month, we will be able to see a different start of the quarter and end of the quarter. So for the two dayses, you can compare; the quarter is also changing. Let's go ahead and add "Start of Year" and "End of Year". So first I'm going to add "Start of Year", and the function I'm going to use for that is "Date.StartOfYear". Unlike the DAX function which can take a second argument for the financial start date, the "Date.StartOfYear" function only takes one argument, that is "Date", and it always gives you the calendar year start date; it doesn't take the second argument. Let's press "OK" to get the new column. You can scroll and validate the different years which you have got, but the easier way is to click on the down arrow and see all the values. You can use; press "Cancel" to come out. Let's add one more column, and this time we are going to add "End of Year". The function which I'm going to use here is "Date.EndOfYear". So "Date.StartOfYear"; I copied; I'm going to change it to "End". Again, this function also takes only one argument; it doesn't take "End of Year" argument. So let's press "OK" to complete. What "End of Year"? You can just click on the values and use "Load More". All the "End of Year"... For a financial year, we have to write down a manual code, so can write down final code. So I will tell you how to write down FY start. I want a financial year that starts in April. What does that mean? That means that if the date of the month is less than four, then the year is started in the last year; otherwise, the year has started in the current year, and I'm going to use all these things inside the #date function. So in the first argument, I will have the logic for the year; the second argument would be month, which is four; and the third argument, day, which is one. This means any date between 1st April and 31st March of the next year will have the same start date of first April of this year. So let's start coding the formula with "if". Now after "if", we don't record parenthesis; "Date.Month"; I want a financial year which starts from April, so if it is less than four, it means the year was started in the last year, then my year started in the last year, isn't it? So "Date.Year" of "Date"; only one argument it takes is minus one as the date of year is the date of year. So if it is four months and above, it is the same year where the year started—only year logic. How would I convert this into date? For that, I'm going to use the #date function. In #date, the first argument is here, which we already sorted out; "form of four for a one", and we copy this and click on "OK". Now you got the year which is starting Financial Year. How do you get the end? Almost similar formula; go to the "Custom Column", and "FY" and date of the same formula, but the thing here is here; if it is less than four, it is ending in the same year, but if it is greater than four or greater than or equal to 4 + 1, it is going to end in the next year, and that is not 41; it is 331; so it is going to end in the next year if it is 4 months or onwards. If it's April, which is my start of year, I'm going to get my financial year end in the next year, March. Before April, whatever months are there, they are ending in this year only—March of this year. Let's click on "OK" to get the new column. Time to focus on "We" columns. We will create "Start of Week", and for that we also have a function. Let's start with a new column, "Start of Week", and we are going to use a date function, "Date.StartOfWeek". It takes two arguments: the first argument it takes is a date column, and the second argument is how do you want to start your week: zero means Sunday, one means Monday, and so on. Click on "OK" to add the column. So you got the Sunday as the starting point. Let's do Monday because 1st January 2018 is a Monday, and when we go give one, it's for a Monday start. I would like to add another column, and this column should provide me a weekday number. So let's add a column, and this column I'm going to rename as "Day of Week". I'm going to use the function "Date.DayOfWeek". "Week" and this function can take up to two arguments. The first argument it takes is a date. As of now, let me create this column with only one argument, so it is giving me the values: one means Monday, and zero means Sunday. If needed, I can go ahead and change this by providing the additional argument into this function. So it wrs as zero as Sunday, one as Monday, and if you don't want, you can actually go ahead and change it by providing another argument, but I think we have find it with that. But what we can do is we can gave the names also. So there is a function to get the name also. We'll go to "Add Columns", "Custom Column"; just create the column "Weekday Name". This column is going to return us weekday name. The function which we are going to use is "Date.DayOfWeekName", and "DayOfWeekName" function takes one argument, that is "Date", and using this argument it is going to return the weekday name. So let's click on "OK", and now we are getting the weekday name like Monday, Tuesday, Wednesday, and as you can see, 1st January 2018 is starting from Monday. Same way, "End of Week" is also very simple. So let's add a new custom column for "End of Week". "Add Column", "Custom Column", and let's rename this column as "End of Week", and the function which we are going to use for this is "Date.EndOfWeek", and this function can also take two arguments: the first argument is "Date".
Comma, the second argument is one, means the week will start on Monday and end on Sunday. So it is ending on the Sunday, the 7th January. This means we have a week from Monday to Sunday. This was little difficult in DAX sometime back, but now we have arguments which is making it simple. Index also, now we are all sorted on the start dates and end date of month, quarter, and year as well as week.
Time has come that we start creating the formatted column, and I'm going to start with a column which is going to give me month year in the text format. So month year, and I'm going to use date.ToText function. It can take two arguments: the first argument is date and the second argument is the format. And here the format is going to be mmm in capital 3M and then 4 yyyy. This is going to give me a format like Jan-2018. So let me click on okay, and we got January, February, March, April.
This will lot sort because, as we know, we need a sort column. If you have a month year in a format Jan to March, it doesn't understand that. So we always need sortable format. So we'll go to the custom column again. We month year sort also. So month year sort, how do we get that? Now we need Date.Year. We'll get the year of the date; we multiply it by 100; to that we add Date.Month. Again, this one takes one argument, that is date, and it's going to provide me the month number. This combination is going to create a sortable month year which can be used as a sort column for the month year name which is in text format. The same manner, you can also add the quarter details using the functions available for the quarter in Power Query.
So you have seen, you know how easy it is also in Power Query. If you know these date functions, you can simply go ahead and create it table. Now there are many other things which are available in date functions like IsCurrentDay, IsCurrentMonth, IsCurrentQuarter, and those can help you in creating this quarter, this month, this year. Those help you to create the columns which help you in defaulting the current month, quarter, and current year into the slicer.
Now you have learned some basic date functions using which you can create the date table, but the date function does not stop here. Power Query provides you a lot of date functions which you can use to enrich your date table and do many other operations which are required. I have discussed quite few of them on my channel in different different videos, so you can go ahead and watch those videos and enhance your skills around the date functions and solve many other Power Query problems using the date functions.
We had a lot of formulas with DAX, and one of the things which we have discussed in the past is there are scenarios where you will not be able to achieve few things using the connected table, especially when you want to go beyond the boundary of what you have selected. What happens in case of Power BI? What you selected becomes your boundary. These, if you have filtered something from slicer or filter, that's your boundary, and you are not able to go beyond that boundary. Within that boundary you can get all the value. So let's say if I select a month, I can't get 12 months as a trend. I can get within the same month the 12 month value, but I can't get a TR of a 12 month. So how to handle that?
Now to handle that, we have something known as disconnected table. Now the disconnected table can give you a solution, and also the table with the inactive join can also give you a solution. So there are two ways you can achieve this problem: one where the slicer is on disconnected table and second where the axis or the group by is on on a table which is disconnected or a table which is joined on an inactive join. Means definitely you require two tables in a scenario. So what I've done here is basically to do this, I would use this file which we are using in end to end, and the 12R with visual calculation is something which I want to use. Now in this model, if you remember, we have connected our date table; the date table is already connected with the sales table, but DateAuto is not connected. And what I've also done here is in the DateAuto I added the MonthYear column and MonthYearS column, and I also sorted the MonthYear correctly. I made sure the MonthYear is sorted in the date table also, because MonthYear is a text column, the sorting needs to... Let me add a new page and tell you what I need is I'll take a slicer from MonthYear. I'll also create a visual on MonthYear. Let me create a line visual on MonthYear and let me bring a measure, Net. Now you can see I'm getting all the month. If I go to the slicer and select any particular month, let's say December 19, I'm not getting 12 months after November 19. I'm not getting 12. So you say, okay, why don't you go ahead and create the rolling formula? You'll get it. So let me do one thing, I have already have a rolling formula, so RollingTwo is there. Let me copy the RollingTwo and create it into RollingWell for dates and period. We have learned this in time intelligence, how can we do that? Oh, I have only two formula. I copied that and let me paste it into a new measure and call it Rolling12. And what I'm doing here is NetSalesInPeriod, DateOfDate. The first argument, MaxDateOfDate is the second argument. From where should I start? How many periods should I go? I'm saying minus 12 because I'm starting with the Max, 12 months. This is 12 months of formula, Rolling12, but Rolling12 what it is going to do here is when I add it here, it is not going to give me 12 months of track for that particular month; it is going to give me 12 months of values, and you, as you can see, this value is pretty high compared to N. You might have understood it is summing up the past. This is the 12 months of TR. So one of the solution which we tell for this one is basic: you don't have this slicer on the connected table. So let me remove this. You have this slicer on a disconnected table, so disconnected or independent table we also call it sometime independent. I'll go to the disconnected table, DateAuto, and in that Auto I'll again bring in this slicer, MonthYear, and this MonthYear slicer. Let we select any value as of now. When I select any value, let's say December 2019, you don't see any impact because it is not connected with the table, so it's not going to impact. Let me duplicate this visual. Let me remove the measures. Now what I want here is I want this slicer to be considered by this visual, but for that I need to create a new measure. So I'm going to click on New Measure from the Home tab, and in this new measure what I'm going to do is I'm going to consider the range of this slicer. Now this slicer is not connected, so it's not going to impact, so it's not going to restrict my date range because it is disconnected, so I can take a date of reference from it, and it is not going to restrict me 1 month or 2 month or 12 months because it is not joined with my sales table, so it is having no impact there. So let me do one thing, let me create a formula, Red12, and first thing which I want to do is I want the date which has been selected here. So before Max equals to MAXX, all selected, this is how we got the max date of DateAuto table, all selected DateAuto, and I need date of DateAuto. I get the DateAuto date. So I got this into a variable. Now what I'm going to do is based on this date I want to create 12 months STR. So I need a date which is also a minimum date. So I got a Max date, how do I get minimum date? EOMONTH is a function. EOMONTH, and I can take Max uh, 1 minus 1 will take one month back. Minus 12 minutes should take me 12 months back, and plus 1 it should give me 12 months of trend or so. We got a minimum value; we got a maximum value. Now this date range is having no impact on my calculations right now, so what I want to do is return CALCULATE Net, and remember there is no other filter required on the date table right now, so we assume there is no filter and we don't need to ignore any filter right now. So now what I will to do is I will push my filter on the date table: DateOfDate is greater than equals to underscore minimum and DateOfDate is less than equals to underscore Max. So DateOfDate is greater than equal to Min and DateOfDate is less than equal to, and we are filtering; we are not putting any ALL or something which is restricting. So trend of 12. So let's get this trend of 12. I have pressed enter so that the formula get committed. I could have also pressed the commit button. So let me drag this Trend12 into the second visual. Now I'm getting a 12 month STR. As you can see, I'm getting a 12 month STR. This is going to work only when you filter from the independent. The moment you filter something from connected table, it will not give you the 12 months Trend, but you always face one challenge: the rest of the visuals and the measures are getting filtered from the connected table, and this one is only getting filtered from the disconnected table, so it is really difficult to manage it on the page. So how can we get it filtered from the connected table? And if I make this in sync, then this visual is not going to obey, so then I will again have a problem. So then how do we do that?
So to do that, what we are going to do here is basically, so we need to make sure that the slicer is on the connected table and axis is on the disconnected table. Right now it is reverse: the slicer is on the disconnected and the axis is on the connected table. To make this happen, we will add an additional inactive join in our data model. So let me do one thing: let me join the sales DateOfDate table with the DateAuto, and this will to create a join. We are going to create a single directional join: the date table many-to-one join with the DateAuto table, but that is inactive. There is a join, but that join is not filtering right now. That was the inactive join, means, and it should be shown as dotted. Dotted means the join is inactive. Now we come back; we don't see any issues, so it means that I can keep my disconnected table with an inactive join also. Now what we want? We want this slicer, the above slicer, the MonthYear slicer to work. And just to understand this better, let me go back to the DateAuto and rename this column MonthYearIndd. Double click, rename, and enter. Let me come back to the relation. So right now things are working. Let's rename the page as Disconnected Slicer, as we are using a disconnected slicer here. And for that I'll duplicate a page to take the next case. So now we have Disconnected Slicer page on which the disconnected slicer is working. Let's duplicate this, and now we want the connected slicer. Now we don't want disconnected slicer, so what I want here is basically on this page a connected date slicer. I don't want disconnected date slicer, so I can delete it and only keep the connected one. Okay, so what I'm going to do is because you want a connected slicer and in the connected slicer you select, let's say November, and you need a 12 months of trend which is not coming on the visual. Let me first of all remove this measure and also remove this axis. Now what I'm going to do is I'm going to bring this axis from the independent table, so MonthYearIndependent. Now when I bring this axis from the independent table and let's say if I try to bring in Net, the measure which we have here on the y-axis, you see a flat line. The reason for that because joinor is not going to work. So now let's we do go ahead and create one more measure from the Home tab. I'm going to create one more measure very similar to what we have created few minutes back, but this time we are going to calculate our date ranges based on the connected date table, not based on the disconnected date table. I'm going to create TrendWellDisconnected. The axis is disconnected; let me be very clear on that. Now again I'm going to create variable Max, and the variable Max is going to be MAXX, all selected date, DateOfDate. I'm going to again have a variable, where underscore Min, and Min is going to be EOMONTH, underscore Max - 2 + 1. Return. I going to return, I'll use CALCULATE Net. How I want to filter? Filter, let me filter DateAuto, DateAutos date, DateOfDate is less than equals to underscore Max and DatAutos date should be greater than equal to underscore Min. Let's try this out. There is still one problem you might have identified that: where is the join disconnected, isn't it? So DateAutos date, DateOfDate is less than equal to Max and N double M perc DateOfAuto is greater than equal to minimum. Okay, let's commit this formula and let's bring this inside the visualization. Now still it is giving us a flat line. How to get rid of that flat line? We have not activated the relationship so that it can work on the axis. So let's try to use USERELATIONSHIP. USERELATIONSHIP is a function which can help us in activating an inactive relationship. So let's take USERELATIONSHIP, the table DateAutos date, DateAutos date with the sales date of sales table should get activated. We are asking it to activate the relationship now, and the moment we do we are seeing only one dot. Why so? This formula needs modification. The what modification this formula needs is that this date table is still needs to give me the 12 months of value. The date table is still giving me one month of value, so there is no benefit of, you know, putting this USERELATIONSHIP in action. What I need here is basically rolling 12 months. When I rolling 12 months, do I really need because now I'm getting 12 months of data? Do I need need this filter? So let's check it out without this filter. So now we have a rolling 12 which is based on 12 months of rolling, and then we are saying activate the relationship of independent table, and now if you can see we are getting the 12 months of data. Let's move it to December, and we are getting data of December. Let's move it to August, September; we have data from October. So as now you can see the axis which is coming from disconnected or independent table is getting... So you need a rolling formula. Now that rolling formula, you just create a USERELATIONSHIP with a disconnected table and use that disconnected table on the axis, and then you can have the relationship. So disconnected is basically inactive. Disconnected, it's not completely disconnected, so inactive disconnected table. You activate that relationship, and then your rolling will become your 12 months of trend. And in this case what would happen basically is that you have the axis which is on disconnected table, so it is your same slicer, your connected slicer or your joined table slicer which is working, so you don't have to change everything on your page in order to create many measures. It is only for the visual where you need this 12 months, you can use the disconnected or the independent table in the axis with with such a small formula, and this formula is going to help you out. Just to compare the the values of the September, it is 245k, and the value of September is 245k. The numbers are matching; it means it is displaying the correct values. So you can go ahead and try this out, and there are different permutations and combination which are possible because of disconnected tables like EXCEPT is one of them. Whenever we have a value and we don't want to use that value, want values other than that, there are so many use cases around that which can be done because of this disconnected or independent table. You can watch all of those in the previous video of the channel. Just search for independent or disconnected keywords on the Channel videos, and you will get the list of the videos which are talking about disconnected table or independent table.
How can we convert a single table into a star schema? Now this single table is the very common file which is available on my GitHub account, which is Beginner Tutorial Series file, which I also used in my beginner tutorial. This is the retail file which is having the entire data in one single file, and you wanted to know how can we convert into a star schema. In this video what I'm going to do is I'm going to give you the video which I've recorded for that particular Series so that you can take the advantage here also on the YouTube. The purpose of this video is to convert the single file into a star schema. So first of all, let me explain you that Excel file which we have. So this is the file which is known as Retail Data on Beginner Tutorial file. This file contains OrderID, OrderNumber, OrderDate, which are the order attributes. Then it has a dimension which is a part of this table only, which is ItemID, ItemNumber, Category, SubCategory, SubSubCategory, and Brand. Then I have UnitPrice, which is the sales price, Quantity, how much we have sold, DiscountPercentage, it is actual discount percentage, so we don't have to divide it by 100. Then we have GrossSales, Discount, NetSales, which is known as Sales, UnitCost, the cost which you are paying for this item. Then we have RequestedDate, DeliveryDate. This also contain the geography item attribute which is City, State, Region, and LocationID, but not all four can be a part of a single dimension. It also have some single column dimensions like OrderType, PaymentMethod, and CustomerID. So using this single Excel sheet we can do the complete analysis on Power BI, but we know the star schema works best on Power BI. So what we are going to do is we are going to convert this single file into a star schema, and I'm going to showcase you all the steps for that. What we have done so far is we have learned some basic Power Query transformation. Now time has come that we apply those transformation onto a data set, and this data set is basically a single table, and this single table we wanted to break into a star schema. So how to do the various transformation to convert this table into a star schema? And to do that, what I'm going to do is I'm going to go back to the GitHub, and from the GitHub I'm going to take this file for Beginner Tutorial Series YouTube.xls. Again, I already opened that file, and I'm now going to right click on the raw copy link. I'll take this link and I'll go back to Power BI. Power BI, I click on Get Data, Web. This URL, click on okay. It will show me only one sheet, and I'm going to pick up that particular sheet, and after that I will click on Transform Data. This will open the data onto the Power Query mode, and we can directly transform it without loading it. This data is a very special data because all the attributes, whether they dimension or measures, are available in one single table. I want to create fact and dimension out of this single table. I'll tell you what all this table contains. This particular data is having OrderID, OrderDate, ItemID, Category, SubCategory, SubSubCategory, Brand, UnitPrice, Quantity, DiscountPercentage, UnitCost, State, Region, LocationID, OrderType, PaymentMethod, and CustomerID. I want to create multiple dimension tables out of it, but how can I do that? What happens when I want to create a dimension on a single stuff like OrderType or PaymentMethod? Then I do have options like, you know, add as a new query or a single column, but I do not have similar option for multiple columns. For that we need to explore the option of duplicating the table. To do that, I can right click on the sheet, and I have two option: Duplicate and Reference. Duplicate will duplicate, and it will take whatever steps have been performed till now. It is just duplicate this code.
And after that, there is no connection between the two tables. But what would happen in case of reference? It's going to create a reference, but it will add the reference to this table, which is Sheet One, whatever it is. The advantage of reference is to load the data for once, and then it's going to process the rest of the things. But in case of duplicate, because it's going to load the data again and again, so every time you take it, it will load the data for all the duplications you have created. So if you have created four duplicates, it's going to load the data four times. Let me show you what happens when I created a duplicate copy. So if you see the duplicate copy, if you see in Sheet One, look at the steps in Sheet One and go and look at the steps in Sheet Two also; they are saved. And if you click in the source, you will see it is getting data from the same place. But now, if I right-click and use reference, you will see that it is referenced in Sheet One. But the disadvantage with that is if I go ahead and do, let's say, one operation here, let's say if I go back and create the gross column which we always create, so I go and create a custom column and let me call it as gross amount. For this gross amount equals quantity multiplied by unit price. Click on okay to add. Gross amount is available here in Sheet One. But if I go to Sheet Three and you scroll, you also see gross amount. It's a reference table; it's going to get everything.
So to avoid this, what I'm going to do is I'm not going to do anything with Sheet One. So let me delete whatever I've created. So I'm deleting the queries. I go to Sheet One; I'll also delete the edit column. Let me rename it as Sales Under Base. I'm not going to do anything with this table. I want to create an item table. So, but for that, what I'm going to do is I need this field: Item, Category, Subcategory, Sub Subcategory, and Brand that constitute my item table. What I'm going to do is I'm going to create a reference table. Our reference table is created now. Let me rename it as Item. Item query has been created, which is going to become Item table. I'll select Item ID, Category ID, Subcategory ID, Sub Category ID, and Brand. If and click, all these columns are selected. I'll right-click and I'll use Remove Other Columns. Remove whatever other columns are there other than what I've selected. Po that I click on Item ID or I click here on the corner, and after that I can use Remove Duplicates. Now it will remove duplicates for the table. And now I need to check here: am I getting the listing Item IDs or not? Because if Item ID is not distinct, then it's not going to become my primary key. So what I'm going to do here is I'll go here to the View, and here let me add Column Distribution. And you see thousand distinct and th unique. Let me click on the bottom and use Entire Data Set, and you can see 264. 264 is unique and distinct; it means Item ID is my primary key or unique key. I don't need an index column for uniqueness. I can use Item ID to join with my fact table.
Let's add another dimension. Now again I go back; I duplicate this using reference and let me call it as Geography and inph. I want to bring the column City, State, Region, and Location. I selected all of them; right-click, Remove Other Columns. I click on the top column and I'll use the option Remove Duplicates. And let's wait for the Location ID stats. Here you see there is a problem, and the problem is: see, there are only 75 unique, but there are 299 distinct. It means not a primary. The cities are 71 unique; there is some problem, and the problem is caused by the Region column. It is not allowing us to get the Location as a unique column. Let's go to the Remove Other Columns tab, and from there we will remove Region as a column. And once we remove this Region as a column, we can press Enter and check for the results. And once we go to the Remove Duplicate step, we will see that now Location ID will become a primary key or a unique key. And now you can see 299 distinct and 299 unique; it means Location ID can be used as a primary key or unique key, and it can also be used as a join column to join with the fact table. Two Dimension tables are done, and now I can go back and look at the data. Now I'm not bothered about Order ID and Order Date, but I would like to create some single column Dimension. So let's go ahead; I'll tell you how to create a dimension for Order Type and Payment Method. For Order Type and Payment Method, now these tables don't have their own IDs also, so I need IDs. And Region also, one of the contenders is Region. So right-click on this, Add, Add as a new query. Now again, when I add as a new query, the query is going to take all these steps. So this is what I don't want; I don't want this. This is one of the best methods to do it, but again you see that all the steps are repeating. This is what we don't want. So we go ahead and remove this, and instead of that we will only go to the reference, and there we'll select one column, let's say Region in this case, Remove Other Columns, and then simply, because it's only one column, we can remove duplicates by clicking on the column. Duplicates are removed. Now here I want to have an ID column, and that ID column I again want back in my fact table when I'm going to create a fact. So what I'm going to do for that, so I'm going to add an index column. Go to Add Column, and there, Index Column starting from one. I added an index. The same exercise I need to repeat for Order Type and Payment Method, but right now I'll just keep it till this example. Let me call this table as Region. So now what I wanted to do is now this Region has a new ID, and I would like to populate back, and then I'll get the Payment ID, then I'll get the Order Type ID. I would like to populate those all. Let's start working on the fact table.
So first of all, let's go to the Sales Base. You click on the Sales Base; you go to the Home tab; you'll use Merge Queries. Merge Queries is new, and I'm going to create a fact table now. And here I'm going to join with the Region Base. Join would be the Region column, Region to Region. It would be a left outer join. Always prefer outer join in the favor of the base table; ideally it should match everything unless we have null values. So let me go ahead and click on okay. Now when you scroll on the right, you see there is a table. Now expand that; uncheck this Use Original Column, and we should have renamed this index column; we have not renamed, so we are going to rename it here now. So let me add this index column, and let me call this index column as Region ID. Now this I can use to join back with my Region table. I will go back into the Region table and also try to rename Index as Region ID. Now once I rename it as a Region ID, the step which you have already added into the merge table might not work as expected, so we might have to edit the merge step. I click on the setting, and I replace it with Region ID. It is giving me a question mark, so I don't want that question mark to continue here, and I'll delete this Rename Column, and now you can see the question mark has been removed. I got the correct name Region ID. Now I would like to rename this Merge One table as my Sales Fact table. How do I add the other things? Let's say if I want to have Payment, how do I'm going to add the Payment ID here? Am I going to create another version of this table, or I'm going to merge with this? I'm going to merge with this. So let's take one example. I will go back to the Sales Based table, right-click and create one more reference of it. You go to the Payment Method, right-click, Remove Other Columns, then again right-click, Remove Duplicates, then go to Add Columns, Add Index Column from one, and let's call it Payment Method ID. Now I need this ID in my fact table. Before that, let's call this table as Payment Method. Now we want to merge the Payment Method with Sales Fact. So what we are going to do here is we'll click on the Sales Fact, go to the Home tab. Now instead of Merge Queries as you, I'm going to use Merge Queries. Inside the Merge Queries, you we will bring in the Payment Method query also, and we'll click on Payment Method, Payment Method, and this again is going to be left join. Click on okay; scroll to the right. Now you can see Payment Method appearing as a column, and the column is the table which we need to expand. Expand that; we only need the Payment Method ID; we're going to take that; click on okay. Our fact is ready. Now our facts and dimensions are ready, and I'm going to click on Close and Apply, and it is evaluating all the tables. So you can see it started on the query for Sales Base, Item, Geography, rating connections, loading data to the model, and the Sales Base table is loading, and respective other tables which are dependent on that are also getting the data. The Sales Fact is still not loaded because it is dependent on all other tables like Payment Method, Region. Now it started loading, and you might have seen that you know Sales Base is not moving at all, and dependent fact table can load. You might have also seen that other tables were not loading as many rows as the Sales Based table, and this is the advantage of taking the reference.
Now we'll go to the Model view. I would like to show you how to create a model in such a scenario. So because we have the setting of detecting the relationship, it has detected the relationship, but those relationships are not correct. What I'm going to do here is I'm going to delete those relationships and going to create all the relationships again. One thing which I'm also going to do here is I'm going to hide the Sales Base. I don't want to see that table now; I'm not needing that, so I close the eye here, so it will be hidden. Now Sales Fact is my main table. Payment Method, Geography, Item are around it. So how do we want to connect? Item ID with Item ID. Where is our Item table? So Item ID, Item ID on the Item ID is, is Fact Item ID equal to Item ID, many to one, single directional join. It is already suggesting that, so let's do that. Then we will create Region ID to Region ID, again many to one, single directional. Then we have Payment Method, Payment Method to Payment Method. This should be one to many, single direction, because we direct from the Payment Method site. And now we want to connect with Location ID, so Location ID to Location ID, one to many, single directional. Click on Save. So now we got all of our joins sorted out. This is the schema which has been created. Let's save this file. So this is the star schema we have created from a single file, and this is very similar to what we were creating using sales data used in video or sales data used in fabric file. That was a perfect star schema, and the four tables were given, but here we have transformed to create a star schema. It has almost similar kind of column. The Discount Percentage here is actual discount percentage, so you don't need to divide it by 100. You can create a column in Power Query; you can create a column index; you have the additional Dimension which are coming in Order Type, Customer. You can also enhance those like in Customer you can add the Customer Name as appending of Customer ID, like Customer space the ID. That what you can create either index or Power. These are a few of the things which you can do and create the schema and try out everything which we have done during this series or video, and repeat that on this particular data model. And this data is much better data. And just to give an example in visualization, if you go here and bring it from the Item Brand, you see some of the actual brand names which has been created in this data, and that is why I always say this data is much better data than the data which we have. It does have a lot of variety. I do have a better version of this data which contains a little bit of more data, and for that you can ping me in the comments; I can give you a Dropbox link; from there you can take this file and load. So this is the way you use the Power Query transformation to create a star schema. We had one table, and from there we created a star schema. There are scenarios where you might have a snowflake schema or a relational schema, and from there also you can merge and create a star schema. So go ahead and try out those different combinations.
In this video, we are going to discuss how can you append all the Excel sheets available into one table. So the case here is that I have an Excel where I have multiple sheets, and all these sheets I want to append into one single table. Even if a new sheet comes in, I would like to put it into the same table. Now how to get data for this one? So data for this example which I'm going to discuss is available at my GitHub account: github.com/AmitChanderPV/powerbi. You can get the append_sheet.xls. In this video, I'm going to use the download version of this file, but I have told you many times how can you directly connect to this Excel sheet without downloading it. What you have to do is you to click on this append_sheet.xls, and I'm going to give this URL to you, which is the raw URL, not the one on the top. So I'm going to post the URL which is: right-click on this, Copy Link Address. So in case you're directly reaching to my GitHub account, you have to open this file, and on the raw, right-click and copy the link, and this is the link you can directly use as the web link in your Power BI Desktop or web API Link in that manner. You will be able to directly get this data onto the Power BI without downloading it into your desktop. So let's understand the use case with an example in the Excel sheet, and then we will try it out on the Power BI Desktop. So basically what I have, I have these three Item sheets, and I want to combine them. And tomorrow there could be a fourth one, and if there is a fourth one, my requirement is that fourth one should also get combined. So in this case, what happens is if I try to get the append idea, the normal append idea where I append the table, how do I add the fourth table? Do I need to modify the code again and again? So I need to have some generic solution which can actually help me. So let's go and try out what actually we do in Power BI. So I came to Power BI, and in Power BI what I would like to do is basically I want to import this Excel sheet. So in the center of the Power BI screen, I have this option Import Excel. I do have Import Excel option here also in the Home tab, and under the Get Data also again I will get it. The option I will use this Import option from the middle and select the sheet append_queries and click on Open. Now once I do that, I'll get all the sheets, and what is the usual way? That click on all these three, check, check, check. So when you check, you get the, you are taking that inside the system, and when you simply click, you just load the data. Instead of using the Load data or Load, I'll use the Transform Data because I want to go to Power Query and combine this data, isn't it? That's what I wanted. So let me go to Transform Data. If I go to Transform Data, and what usual append method is there, and let me bring the Power Query on this screen. If I want to combine these three, I need to take that usual append method, isn't it? So I need to go to, you know, Append Queries, Append Queries as New, or Append Queries, and then I need to say two or more tables, and then I say Item Two and Item Three. I click on the Add, and I do that, and it is going to append all three sheets as queries into the Item One query or table. That's not something which I wanted. Because let's go ahead and add something here. Let's go ahead and add a new sheet here. I also want the header, so let me go back and take the row from the top and paste it here on this sheet. Now I have the header. Let me change the values 41 to 56 and 47 to 57. We can use this sheet. Let's keep everything as same. Now I got one additional sheet. Now if I go and refresh this data, I don't get the sheet four. So it means there is no benefit of this. So let me do one thing; let me discard all these changes and do it again. So I discard all the changes; I come out; I say Discard all the changes, and I'll do it again, and now also. So what I need to do is I also need to delete the sheet. Let me delete this sheet and save it. Let me go back and import the append_sheets Excel workbook again, and this time I'm only going to select Item One, and I'm going to leave out the other sheets. With only Sheet One, I'll click on Transform Data to reach Power Query and start the transformation again. Because I press Transform Data, I reach Power Query. In Power Query, I also remove these steps. Now you can observe that I'm seeing all the three sheets as my source, and the data is available inside the Data column. If I go here, you can see that I see a table, and that the challenge with this table here is basically the headers are not promoted. So I have the table which is having the data, but headers are not promoted. I can expand it; I can expand it here, and you will be very happy to see that all the data is together. But what is happening here is this headers are NSC. Then you will say, okay, we can search the column name, and then they remove those rows, and then do it. But what happens sometime you might have a scenario where the column name which you are taking might also exist in data. So for that, what we are going to do is if you are a follower of the beginner series, you might have remembered we learned function Promote Headers, and using that function Promote Header, we can actually do a promote header in a table. We are going to do is today we are going to use that Power Query function. So to do that, what I'm going to do is I'm going to go to the Add Columns, and I'm going to add a new column. Remember here my complete data is available as a table in the Data column in each row, and if I click on the empty space, I can preview the data. Always click on the empty space; don't click on the name, otherwise it will add a step. Let me add a new column, Data1, and inside this Data1 column I will use the function Table.PromoteHeaders. This function requires one argument, and that argument is the table for which it is going to promote the headers, means going to make the first row as the header. Let me add Data column as the argument for this function. I double-clicked on the name, so once I double-clicked on the name, it also appeared. I can also type; it will also come. In that case, either I type, I double-click; in both the cases it will work. So now it's going to create one more column. I created one more column. Now look at this column; for this column headers are already promoted for each of the rows. As of now, there are too many columns here, and I can delete them. I can even delete the Data column. So let me select the columns which I doesn't require other than the name of the sheet which I might require for the future references. I have selected all the columns which I don't need, and now I can use the option Remove Columns and remove all these columns from.
The table now. I'll go and expand it. It is suggesting me all these columns, and I say okay. And then I can detect the data type and change it. So now I'm able to expand and get the data together, and my all data is now lying together. The question arises: will it take a new sheet when we add it into the Excel? So let's go back to the Excel and try to add a sheet and see what happens. Let me copy a couple of rows for the new Excel sheet and click on the plus button, and I will call this as item 4 sheet. And this item four sheet, I will add those couple of rows and modify the data. So item id 56 and item id 57, I'm adding here in the sheet 4. Save it and go back to the power query. Now we need to refresh this data. So let me click on refresh preview. You can observe immediately that item four and its related data has come. Let's go to the source, and now we can see item four there. Item 4 is getting processed in each step after that. It means the data of the item four is carried forward without doing any changes in the code of power query. If needed, I can correct the data types, or I can simply go ahead and click on close and apply, and I will now get this data into my Power BI desktop. And I can save the file and move on in our journey to learn Power Query.
Let's learn Power Query by taking an example. And in this process, we are going to learn few Power Query functions. So what we wanted to do here is we have a text which has certain numbers, comma separated, and we want to create another text where these numbers are sorted. So let me take you through an example. So I have this string where I have 7A, 5A, 6A, 10A, 11a, 2A, 4A, 3A, 8A, 9, one. So these are just randomly placed here, but I want ascending sorted text: 1, 2A, 3, 4A, 5A, 6A, 7A, 8A, 9A, 10A, 11 in a sorted ascending order. But it is a text in the given order. I want these numbers. So how can I do that? And to do that, what we are going to do is we are going to go to Power Query and solve this problem.
Now, to solve this problem again from this series learn Power BI, I'm going to take n to n14 bbx file, and I am here on the Power BI in that file. In that file, I'll go to the Home tab, then I'll go to transform data. Transform data. I have reached transform data, and inside transform data, I want to add those numbers which I have told you. So I already copied those numbers to get those numbers inside a table. I'm going to take help from enter data. Now, enter data is something which is also available outside Power Query. You might have seen that inside the reporting view also. Let me click on the enter data inside the Home tab. It opens up a popup. Inside that, I'm going to give that string, and I'm going to name this column Text One, and the table is thought Text. I'll click on okay. Now this table will get loaded inside the Power Query and will be shown on the left-hand side as a query. Now the moment it gets loaded, you can see it is showing a number, and we were never expecting a number, and this is because there is a change data type step which has been added by Power Query thinking that it's a number, but it's not a number. We know it's a text. We don't want to perform this change data type step. I'm going to delete this step from the right-hand side, and now I got the way I wanted the number without a data type number. So it's a text data type, and this is the correct thing. I have what I wanted to do. First of all, to sort this text into a string, I need it into a list format because in list I have a function List.Sort. Maybe in a table format, but here it is easy to do all the operations in the list. What I'm going to do is first of all I'm going to add a column in the tab. Add column. I click on custom column to add a new column, and in this column I will first of all convert this into a list. So I need the sorted text column as a first step. I will do this operation which is Text.Split. Text.Split function can take two arguments and convert a text into a list by splitting it based on the separator. So argument one is a text, argument two is a separator, and the outcome is a list. So what is my first argument? Text one, and the second argument is comma, which I'm going to give inside the double quotes. And let me click on okay to get the result results. Now you will see that I got a list, and you can see this is the list which I wanted. And always remember whenever you get these lists or tables and you want to view them or preview them into the bottom, always click on the empty space. Don't click on the list because if you click on the list, it will add a step, and it will become part of your query, and then you have to revert it to come back. So now it's created that list. So let me delete. So I'm back to the same place. This is my list. Now I can sort it using List.Sort. And once I sort it, you will realize I have one problem. Now onwards, I will keep on putting a function on top of another function to get the nire output. So let's put on top of it the function List.Sort. I got the function List.Sort. It requires two arguments: the first argument is the list, and the second argument is the optional comparison criteria. And you might have realized I have given a space. The reason for giving a space before I selected List.Sort is that it should not replace the Text.Splits. And let me click on okay. So we got a sorted list. Let's have a look at it. So now what we have done is we have used this List.Sort function which can take a list, and it can sort it. But you can see this list is sorted in a text format. It is not being sorted as a number because the list which you have inside is actually a list of x. x.Split converts into a list of text. Then how do I convert them into the number? So it means before I sort it, I need to convert them into a number. How do I do that? Let's open the formula using the right-hand side setting icon. To do that, I need to use another function, and the function I need to use is List.Transform. List.Transform function and transform the list based on a function. The first argument of this.Transform is a list, and the second argument is the transform function. So what I need to do is I need to use this transform function, and for that I need to loop, and for to loop I need to use a keyword which is each, and I can use this each on underscore. But what I want on this underscore? I want to convert this text, each text which is underscore into a number. So we have function Number.FromText, and inside that I can use this underscore which will get converted into the number now. So let's look at it what we got now. So we got List.Transform. The first argument is a list which we created. So the second argument is each, mean which is the looping function Number.FromText. So from the text I'm going to get the number, and what is that text which is underscore which is the each element of the list. We are closing the list, and let's try to close the List.Sort also. No syntax error. Let's click on okay. Now we got the list again. There's no error. So let's click here. Now you can see it is 1, 2, 3, 4, 5, 6, 7, 8, 9, 10. So now the list is properly sorted in the numeric order. Now we got a list. So we need to create a comma separated text from that. So now we need a function which can concatenate this list. Let's edit the formula once again. So let's look at one function Text.Combine. What does it do? Text.Combine can take two arguments: first argument is a list which is a text list, and the second argument is a nullable separator. It means the sep operator which is going to be used when we combine and create a concatenated text. This function returns text, but there is a challenge. It needs a list of text. Let me showcase you what happened if I don't transform this list. As of now, for the first argument is a list which is right now a number list, and the second argument is a separator comma which I have given here. And let's try out. Does it work? Does Text.Combine work on the number list? Click on okay, and it starts giving error, and the reason for the error is the type is not correct. Right now it's a list of numbers. So we need to do the same operation in the reverse manner which we have done some time back. The List.Transform previously has transformed this list into a number list. Now the same operation needs to transform it into the XT. So I have moved down a code little bit so that I can only understand this function. So now here I need List.Transform again. So I'm going to use List.Transform, and on List.Transform now I need to do operation which is basically again this each operation, but not from text. I now need to convert into two text. So Number.ToText is the operation I want to perform, and that should close my transform after transform comma so that I give the second argument of Text.Combine. So what is happening here is now this List.Transform is going to convert my list which is already sorted which is coming from List.Sort into a list of text elements, and then the Text.Combine can combine it into a comma separated string. Let's click on okay and check it out. Does it work? So now what has happened is we got a comma separated text in which the previous text elements which were comma separated are now sorted. You can see I'm getting 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11 as a text which is a comma separated number text, but it is the sorted version of the Text One. So this is what exactly we wanted to achieve. But while doing this example, we have learned text function and list function which we can use. We also learned how to take advantage of List.Transform function which is a very powerful function which allows you to do many transformations. And this is just one example of the transformation where I want to transform each element into a different data type, but you can do many other operations using List.Transform. And I have covered these functions as part of my beginner tutorial series with some other examples also. So you can learn more about all these functions using that particular series.
Try out this exciting example. How do we make sure that these changes are saved? So we can go to Home, close and apply, so that all our changes are part of now Power BI, and we can save this file by pressing Control S or by clicking on the save button. So let it load the data of the sort text table, and post that we can save it. So I'm saving it, and you have to try this example out. You can create any comma separated text for this video and try it out. One of the best ways to learn Power BI or Power Query is to take up some examples and try to solve them. We are going to take one example in this video which is split and distinct. Why? The example will look very simple to you, but most of the time I found when people try to solve this problem, they take one small step wrong, and then they try to solve it by a little different way which is not so effective. So let me first of all tell you the problem. The problem is basically I have these comma separated texts like a, b, c, a, b, c, d, and so on. I have many like what I want is across all these rows. I want the distinct codes which are available like a, b, c, d, e, f. So basically what is happening, this is going to be splitted, and after splitting I need distinct. Once I reach Power BI, I'll tell you where when people answer this question, they commit the mistake. So let's try to solve this problem on Power BI. And to solve this problem, I'm going to use end to end 4 file which we are using for the learn Power BI series, and I am on that particular file right now. In the Home tab, let me click on transform data. And inside the transform data, I will again click on transform data, and I'll reach to Power Query. As this is a very simple data, this can be created with enter data. So let me enter this data. So I'll go to the Home tab and click on enter data. I will be able to enter this data. A popup is open, and here I'm, I'm going to rename the column as Codes, and I can call this table as Codes Plate. Let me start creating the rows for this table by entering the data. Let me start typing a, b, c, and in the next row let me type a, b, c, d. It is not necessary that you type the same stuff what I gave to you. You can have a little different version. That's absolutely fine. So this is the data I have, and let me now click on okay to get this data in Power Query. It will add a query which I'll be able to see on the left-hand side, the list of queries where I have, and I will explain you the transformation needed to do that. So I got the table. As soon as I told you this problem, the first answer comes to you: okay, we will split it by delimiter. Yes, that's correct. So you can right-click and do split by delimiter or inside the transform tab you have the option split column by delimiter. So from any of these options, click on that split column by delimiter. On this popup you have various options. The first option is how you want to split it. The default option is comma, and we have comma separated string, so we are going to use that, but you can change it. You can even choose a custom one. Second is split at leftmost, rightmost, or each occurrence. In this case, we need each occurrence, but depending on the need you can choose. Next option is Advanced options, and inside the advance option there is a choice. If we choose the wrong one, we may get a little longer solution. We may still be able to achieve it, but that's not the optimal solution. In this Advanced option, I have option split into columns and rows, but usually people tell me that we'll split by columns, and then they tell you, no, we will do unpivot and do that. You don't need to do that actually. You have a better option: split into rows, because that will actually convert it into rows, and when you do split by column, it does ask you the number of columns, so you're limited by the number of columns. In case of row, you are not limited. So if there are four, five, six, any number, it will take care of that split because it's going to create new rows. After you do that, you click on okay. Now we got all the codes into the rows, and the next option is very simple. So I right-click and use remove duplicates option. Let me click on that, and we got the desired outcome. As you can see, this is the problem which we can sort with what we have learned so far. There is nothing new, but it is just a use case to pay little attention how are we going to achieve this. I have kept this use case for your reference. You can solve many other different problems by combining various Power Query operations. So try this out.
In this video, we will continue our journey of learning Power BI and Power Query with some examples. The example what we want to take here is the split column, but there is a twist. The twist here is that in the column I have two sets of values. The one value is a single value, then there is a space, and then there's a comma separated value. I want to split them, but the final answers should contain them in a combined manner. So if you look here, the best 1, 2, 4 is going to become best one, best two, and best 4. Similarly, good 1, 4 will become good one and good four. So how can we achieve this? Again, we are going to use some of the things which we have already learned in Power Query, but try to fit in this use case. For this use case also, I'm going to use pyot data.XLS which is available on my GitHub account, and that is the same file we have already loaded in end to end 14 PB. So we can continue to use that particular file. Those of you who are directly jumping onto this part of the video, you have to go to my GitHub account: github.com/amitchandak/PBI-PowerBI. You have to go down; you will find a file pyot data.XLS. Click on that. One thing is you can download this and use it, or the second thing is right-click on the raw. Don't take the URL from the top and copy link, and that is the link which you can use as web URL in your Power BI to load this data. In this case, I have tried out this operation on a little different file, but you can continue with the file you are already having. The pyot data.XLS file. Let's try this out on Power BI Desktop. data.XLS has undergone many changes over a period of time, but for this use case you should be able to get the data inside the file. But if you don't get, you should be able to create this data easily using the enter data option in Power Query. You should be able to get this data inside the Combined Split Sheet, and as we have discussed, the best space 1, 2, and 4, I would like to split like best space one, then I would like best space two; they would be in the continuous row. So let me move it up, and best space 4. Same manner, I'll get the data for nice and good also. So this is what the final outcome I want, but as of now let me clean it up, and let's keep this file as is for our uses. This is not going to be a simple split problem. First of all, we have to split the name and the rank into separate columns, then we have to further split the rank into multiple rows, and then we have to combine these again back into one single column. Two operations going together: split and combine. Let's jump on the Power BI desktop. I'm going to load this data again, but you can continue with the file where you have already loaded. So I'm going to use recent source, and from there I'm going to take pyot data.XLS, and in the pyot data.XLS I have all these sheets which I have showcased you in the past. From here we would like to take the Combined Split Sheet which has the desired data and directly go to transform data. So we will reach Power Query. As our data is complete text data, it might not detect the first row as header, so we have to manually go and use first row as header from the menu. First step is to split the column by space into two columns. For that we need the operation split column by delimiter. So split column is available here. I'm going to click on that, and in that we have many options. I'm going to use by delimiter option. Let me click on that. It will open a popup. In the select delimiter, it has correctly detected the space as the delimiter; otherwise we can change it. We have to go to the Advance option, and inside the advance option we'll choose column, and we'll keep the value two which it has detected correctly. Now we can click on okay to complete this operation. So we got now two columns, but when we look at the second column, we found that the text which we are expecting is not correct. It is not comma separated value, and the reason for that is the auto conversion. You can see the data type is 1, 2, 3. There is a step added: Change Type To, which is converting it into the numbers. Previous step has the comma separated value, so we need to delete this step. Once we delete, we'll reach to the last step where we see the correct comma separated.
Value whenever you do Power Query operations, sometime the Change Type step is automatically added. In such cases, you can delete such a step.
Whenever you are working on Power Query, if something goes wrong, please check it step by step by looking at what is happening on each of the steps. We need to split the second column into the rows; so again, we are going to use the Split Column option. So let's select this column and use the Split Column by delimiting. And once we get the popup, we can see that it has correctly detected its comma separated. And in the Advance, we need to use rows, not columns, for this time. Let's click on OK to complete the operation.
As you can observe, that now we have the values required, but they are not in one column; they are in two columns. We are getting "best" in one column, "one" in the second column, "best" and "two" in two different, different columns. But what we need to do is we need to combine them into one single column. So we need to perform another operation for that. Now we need an option "Merge Columns". "Merge Columns" is available under the Transform tab. We were on the Home tab; that option is not available in the Home tab; that is available under the Transform tab.
In the case of Merge Columns, the order of selection is really important. So first, I'm going to select the first column, and then I'm going to select the second column. If you change the order, you may get a different result. So let's select the first column, click and Control, and select the second column. From the Transform tab, let's choose Merge Columns. A popup will open, and here we'll choose the separator as space, and we will give a new column name, which is "Name Rank", and let's click on OK.
So now we got the desired outcome. The desired outcome contains "best space one", "best space two", "best Space 4", and so on. So this is what we wanted, and as you can see, we have used the standard Power Query menu options only to achieve this. Power Query can solve many complex problems using these menu options or the Power Query functions. The only thing is you need to learn Power Query in detail to achieve that. My advice would be to also look at all the functions which we have discussed in the beginner tutorial series to make sure that you are able to take full advantage of Power Query.
In this video, we are going to discuss subcategory index or subcategory rank. We call it nested rank or nested index. There is a video from Kerbal on that; that is the inspiration for this video. Yeah, going to use the technique shown there to get the subcategory index and subcategory rank.
The functions required for subcategory index and subcategory rank, the rank and the index function, I have explained to you already in the beginner tutorial series. You can watch it there. I will give you a brief overview of those functions here also. Let me show you the two functions I'm planning to use today. The first one is `Table.AddRankColumn`, and the second one is `Table.AddIndexColumn`. Both of them we have already discussed inside the beginner tutorial series.
Now, the challenge which we are going to get here is this function works at the table level. So I cannot give a kind of a partition to give me subcategory Rank, and that is what we have to learn. How can we make them to work for a particular portion of the table, or partition of the table, or category, or subcategory? For example, let's say my table has Brand; I want everything to rank inside a brand from one to any.
For subcategory index and rank, what I'm going to use is I'm going to use the `pivot data.XLS` which is available on my GitHub, and that is the same file we have already loaded in end-to-end 14 PBI. So we can continue to use that particular file. Those of you who are directly jumping onto this part of the video, you have to go to my GitHub account, github.com/amitchandak/PBI/powerbi. You have to go down; you will find a file `pivot data.XLS`. Click on that. One thing is you can download this and use it, or the second thing is right-click on the raw; don't take the URL from the top and copy the link, and that is the link which you can use as a web URL in your Power BI to load this data. In this case, I have tried out this operation on a little different file, but you can continue with the file you are already having, the `pivot data.XLS` file.
Let's try this out on Power BI Desktop. I'm on to the Power BI Desktop now. Let me go to the Home tab, Transform Data, and Transform Data in Power Query. I already have multiple queries or tables, and one of the tables I have is this `pivot data`. I have called it "Name", "Subject", and "Marks", and here "Name" can become that logical division inside which I can rank or index my subjects. So let's first try out to add the subcategory index by name. So for that, we need to use the Group By function first to group this data. So I click on "Name", and I'll go to Transform. Inside the Transform, I have the option Group By operation. Group By and its functional I have already explained in this series, and in this video also, I have explained the same thing in the beginner tutorial series, and I'm going to click on that option Group By. In the popup, I will see "Name" as Group By. Also, observe a new column name as "Count", and the operation as "Count", which I'm going to change to "All Rows". That will disable the column option. Let's understand what we are trying here. We are trying to group this data by name, and we want a column which contains all the rows. So the operation is "All Rows", and now I would like to click on OK to get this transformed table. I do that; I see a column "Name" and a column "Count" with the table inside each row. If I click on the empty space, I can see what data each table contains. The table has "Name", "Subject", and "Marks" for each name. The next step is to add a column from "Add Column", "Custom Column". So let me first of all name this column as "Index". The function which I'm going to use for this is `Table.AddIndex`. `Table.AddIndex` can take table, index column name, start position, increment, and the data type to give us the index. The argument would be "Count", which is a table, comma; the second argument is the name of the column which I wanted to give, which is "Sub Index", comma; now it is not showing because the table is doubled out here, so I'm going to remove the table, and now it will suggest me after the comma. So I want to give the start position, which is one, increment which is one, and it is asking for a data type as the last argument, which I can give `Index64.Type`. So we have to return a type, and here I'm returning `Index64.Type`, close parenthesis, and click on OK. Try to look into the data of each table. Now I can see "Sub Index" inside it, and now what I can do is I can delete this "Count" column; it is no more required, and then I can expand this "Index" column, and I can uncheck the "Name" because I no more need that, and let's click on OK. Once we expand that, you can observe that the indexes are inside the name, and after that, they are repeating inside the second name, and that is what we wanted to achieve. Index is typically based on the order of loading; it is not based on the marks or the subject or anything else, and that is where we need the rank column to define order based on a column.
To showcase you subcategory rank, we are going to do a little complex operation, and I'm going to showcase you how you can add another table inside the same code. So first, let's delete these steps and reach till the step we have "Edit Column" where we have the table. Let's remove the steps and reach to the table, and we are going to open that step again by clicking on the setting icon. I will now showcase you how to do a complex operation in a column. For that, first of all, let's move this table down and write down `let`, and after that, we need to create variables for the table. So let me put this table inside one variable and put a comma after that. In the next line, I'm going to put another table name, and here I'm going to do the operation `Table.AddRankColumn`. `Tab1` has "Index", and in `Tab2`, I'm adding rank to the same `Tab1`, which is having "Index". Let's remove the duplicate table and now understand the syntax of this one. So we require a table which we are getting from the last step. The next one is the column name which we are going to give the rank column name, and the third argument is the one by which we are going to decide how we are going to rank, and to do that, I go back to the documentation and bring in what all values I need to give. So I'm going to copy this, and I'm going to change it once we reach back to our code. So let's take this and put it inside our code onto the Power Query. We need to provide our own column name in place of "Revenue", which is the rank column, and the column which we plan to use here is the "Marks"; that is what is available in our data in the double quote. Then the order is fine; I can keep `order.Descending`. The next thing we need to define is the rank kind, and we are going to keep the values what we have got from the code. So `rankKind` is equal to `rankKind.Competition`; we are going to keep it the same what we got from the documentation as of now. Now we need to return it because we have used `let`; so we need to use `in`, and we need to use `in` in small, and after that, we need to return the `_Tab2`. Click on OK to complete this custom column. Now, if you observe the table, you can see the "Index" as well as "Rank". Instead of adding the multiple steps what we have done inside within the same custom column, we added both of them. Now you can see "Rank" is based on the "Marks", while "Index" is based on the order we loaded the data, and when you do the rank column, it does change the sort order of the table. So that is why first you should do the index operation, and then you should use the rank operation in case you need both of them together.
In the rank, we have a few more options which we can explore. So let's go back to the formula, and here in the `rankKind`, I can choose different options: `Competition`, `Dense`, `Ordinal`, and `Type`. So those of you who have already worked on the rank knows that the dense rank is a little difference. In the case of the dense rank, we get the next rank whether the rank repeats or not. So if you look below here, you have a rank which is one, two, and then we have the two again, and then we have four. So basically, it is kind of a skip rank, but what we want is dense rank; it means one, two, and three. So even if there is a skip, we should be able to get the next rank, and that is what happens in the case of dense rank. So let's make it dense rank and try it out. So now let's look at the data. So we have the different, different kinds of ranks. Let's look at some different rows. In this row itself, if you see one is repeating, but we still have two after that. Then in this one also, we have one, two, two, but we have the next rank is three. So basically, even if the rank is repeated, the next continuous rank is coming. The "Count" column we created using the Group By is no more needed; we can delete it now. Let's expand the data by using the expand icon on the right top. We can remove the "Name" and click on OK, and now we are getting "Rank" as well as "Index" inside our table, the subcategory rank and the subcategory index.
So here we have used the table operations, and table operations is something we have not discussed in this video or series a lot, but you can go ahead and watch the beginner tutorial series to understand in depth how to use table operations. And if you want to execute those operations at the grouping level or subcategory level, you can utilize the trick I have shown you in this video.
We have learned a lot of Power BI stuff, and now we are ready to create the pages, report pages, on the Power BI Desktop which we want to share with other users. To share it with other users, we need to publish the file. Publish the file to Power BI service. Power BI service is nothing but app.powerbi.com, and from there we are going to share it with other users. We'll have a quick overview of Power BI service. In Power BI service, the report has to go to a workspace, and that particular workspace is something which we should create, and in that workspace, we are going to publish this file. After we publish this file, the file will get divided into two parts. Right now, it's a single file. Here in the case of import mode, there it will be divided into a data set, semantic model or data set, and the visualization file. Ideally speaking, we don't want to create any visualization in the file where we have the data model and the measures. We want to publish it and use the data set as a live connect and create the visualization there. And because of the same reason what I've done is I've deleted all the pages because I don't want to create visualization on this file. I want to separate out my model development from my visualization. But before, even if I publish this empty file, and this empty file, because it has one page, it's going to create a visualization file which we may not want it to use. We can come back, use the data set, and create a file. Now, before I publish this, I need to make sure that my measures should get organized in a proper manner. I should clean up unnecessary stuff. So definitely, I don't have any unnecessary tables because what we have done during this entire video, we have made sure that we create different versions of the files, and whatever is not required, we have not added to this, but we have different places where we have measures. So some of the measures are lying here and there in the customer table. We have so many measures. So definitely, would like to restructure that, and to restructure, we already learned that you can go to the Model view, and into the Model view tables. This is the best place to move the measures across. So let's say I have these "Brand Gross", "Brand Net", "Brand", "Brand Net to Brand"; all these you can control and click or shift and click; you can do that, isn't it? And I'll not collect the "Brand Color" because "Color" measure I want separate. So all these "Brand Color", where should they, where they should go? Already there are in the measure folder. These are my filter measures; I filter this, so I can create a folder "Filter"; I can add them there, so they will be moved to a subfolder. Now "Brand Color", "Category Color"; they are color measures, so I can put them into the "Color" folder, and whatever folder I create, I need to remember the name because if a new thing comes in, I need to move that in. Now I have "Gross Two", "Gross Three", "Gross", this "Gross Max Sales", "F Sales"; I need to move to "Others". Now what I'll do, I'll similarly create few folders like "Time Intelligence", this, that, and reorganize all my measures. Also, the measures which are in the customer table, I would like them to move to the measure table and put them somewhere inside the folder. I moved them into the measure folder; then I select all of them, and then I can move them into the "Display" folder, which is TI, "Time Intelligence". These can also move into PI. I am almost done with cleanup. I have mostly organized the labels inside the measure folder, other than one or two exceptions which I wanted to keep in different tables.
Now, one of the preparations which you also required on the desktop is to install the on-premise Gateway. But what I've done is basically I have used the files which are on GitHub, which is basically online, so I don't require on-premise Gateway. But if you're using sources like Excel sheet, SQL Server, which is on-premise, you need to install the on-premise Gateway, and typically on-premise Gateway needs to be installed on a machine where it can be up and running always, and it should have access to Excel files, those local databases which you have, and that will help you to refresh your data set on Power BI service, which we'll understand in a short while. Once everything is ready, we are ready to publish the file now. But before we publish the file, let's understand what is this Power BI service and how do we create a workspace where we can actually publish our data. So we will go to Power BI service, understand its components quickly, create a workspace where we can publish this file. After publishing this file, we have a data; we will get the data set back and create a report. Now we can create a report on Power BI service, or we can create a report on Power BI Desktop; both are possible. Once we do that, let's save this file, go to Power BI service, understand its components, create a workspace, come back, and publish this.
I'm on Power BI service. Power BI service is nothing but app.powerbi.com. Make sure you have created your login as I explained earlier; either you have been assigned a license by your admin and you have got the login for app.powerbi.com, you're using that, or you create the one. Now app.powerbi.com, which is also known as Power BI service or the web version of the Power BI, is for collaboration. It's for sharing whatever content we create; we share that content using Power BI service with other users. Now, to share the content of Power BI, you need licenses; you need Pro licenses, you need PPU licenses, or you need capacity. Pro users can share with Pro users; PP users can share with PP users. So that is user-based licenses. But if you buy a premium capacity, which is either P1, P2, or P3, in these capacities, first of all, you get exclusive capacity to run your Power BI, which is needed for large organization applications. But in the premium capacity, only for designers, you need a license, and you can use a Pro license for that. Before premium capacity, every user, whether it is a designer, report designer, or report creator, or report viewer, everyone requires a license. But after you get premium capacity, not everyone requires a license; a viewer doesn't require a license. In Power BI service workspace, you can create apps, and you can assign that to an unlimited number of users. When you come to Power BI service, you will see a few sections, and let's understand these sections. I'm right now at the Home tab, and where I'm seeing this "Recommended", "Recent", "Favorites", and "My Apps". On the left-hand pane, I have "Create" for a new report, browsing the content. One leg "Data Hub" is for the Microsoft Fabric, which is again accessible using app.powerbi.com, and I've enabled the trial, so you will see the content of Microsoft Fabric. Then "Apps"; in case we create the service app, we will have the apps here. In case you have created matrices, you will have them here. "Monitoring Hub"; in case you have access to Monitoring Hub, you will have it. "Workspaces", which are essential for data sharing, are available here, and "My workspace". "My workspace" is the workspace; even if you're a free user, you will have your own workspace; that is known as "My workspace". Now, to create your own workspace, you need to be a Pro user, and you also need to have permissions from your admin to create these workspaces. Now, workspace in the Power BI world, it's a container of resources like reports, paginated reports, dashboards. We have something known as Power BI service dashboard, which is different from reports. Most of the time, for practical purposes, what we call a report in Power BI is as good as a dashboard in the BI world. But we have a Power BI service dashboard where we can put in the content from various other reports. So all these components can be put into one thing which is known as workspace. From workspace, I can apply row-level security, RLS; I can distribute the content to the selected set of users. All these are possible using the workspace. So first of all, what you are going to do, under this workspace, there is a button below "New workspace". I'm going to create a new workspace. I'm going to give it as a name, and because we have created end-to-end videos, so we are going to give it as a name "End to End". The description is also "End to End". I have not created any domain, so I'm leaving it. I'm not also giving an image. Under the Advance, instead...
Of trial, I'm going to use it pro. I have a pro license or PPU license. I can create that. Pro is basically the minimum license required for sharing or PPU. So we can create a premium per user workspace. And when you create a premium per user, you can use large semantic model, also format. Also, we are using the Power BI reports, so PPU workspace or premium for user workspace, we are creating. Now click on apply. The moment you click on apply, it will open your workspace, which is empty. And when you click on the new, it will show what all components which you can create in Power BI service: report, paginated report, scorecard, dashboard, semantic model, data flow. It is also known as now data flow gen one, data M, and streaming data sets. The more options contain these as well as what you can use in Microsoft Fabric. You can watch my series on Microsoft Fabric to know more about these. You have so many things. I'm leaving that explanation right now; we are only focused on the Power BI content. So Microsoft Fabric, you can watch the videos on Microsoft Fabric. Let's go back to the workspace. You can upload certain content from OneDrive, SharePoint on the workspace. You can create an app; app is for the sharing. We will learn that. You can manage the access; you can share this workspace with other people. You can give the name and share it. And there are four types of roles: admin having access to everything; member having access to app but not having access to admin; contributors having access till reports but not having access to app; and viewers only have the viewer access. You can look for an article, Power BI workspace roles, and always get the latest on what a particular user can do. And as you can see here, various capabilities have been defined what each user type can do. And remember the RLS or the row level security only applies for viewers. So all the users mostly are going to be viewers. So then we have workspace settings. We are right now only interested in a couple of settings that are related to Power BI general setting. And in this one, the important setting which, if you want to allow your users to update the data set, then you need to allow this model setting. They will be able to update the model online using this, so you need to check that and allow contributor to update the app. If there was a feature where it was written if allowed, this is that if allowed, you want to allow the contributor to update the app, then you can allow that. Okay, so now the contributors can also update the then data connectors; no changes; embed code, right now no changes; rest I'm leaving as is. Now we don't need for our initial learning that one. So these are the settings for the workspace. Now, if you are a Power BI admin, you will also be the settings which are under admin portal. Under the admin portal, most important settings are lying under the tenant settings. Definitely, if you have capacity, then you would go to premium per user and capacity settings also. Then there are organizational visual settings which are separately available. If you go there, you have the visuals; then you can add them there, workspaces and custom branding, etc., is there in the tenant. Everything which you do on Power BI service can be controlled. You want to give the help information, you can give. And most of the settings, if you enable them, they have two to three options: for entire organization, for specific Security Group, and these are emailed enabled Security Group. Anything which you want to use on Power BI service, it should be emailed enabled and accept. So most of the time you will get these three settings; sometime you may get one or two, but that depends on that particular setting. This is basically to get the help. I disable it and cancel it. Email notification, if you want to receive your custom messages. Now, workspace, want to allow to use the create workspace or not? I have allowed it for the entire organization. Use cementing model across workspaces means I create a workspace, I create a model or data set in one workspace, and I want to use it in another workspace. So what we will do is we'll create the data set in workspace and reports in another workspace, so that particular users of that workspace will not see the data set in that particular workspace. So these kind of stuff we can do. Block user from reassigning personal workspace, my workspace. So we have disabled that; they can't reassign the personal workspaces. Define workspace retention period; you can define a workspace retention period. So basically, deleted workspace can be recovered after that. There you have n number of features like every export you can do like publish to web is controlled; copy paste visual is control on service; export to Excel from service is control; export to CSV is control; download report is control. All the features which are available on Power BI service, most of those menu items are controlled from here, including which SSO is enabled, which is not enabled. There are certain visuals which are allowed or not allowed, including your map visuals. All settings are available here: developer setting, admin API setting, gen one data flow, people can create it or not; template app and you want to create the app; Q&A settings; semantic model security; block republish and disable refresh package; that setting is available; advanced networking using a your private link; metries setting; user experience experiment; share data settings; inside setting; data Mar setting; data model setting; quick major settings; scaleout setting; one leg setting; G integration setting. So many settings are there; we can spend days in explaining those, but this is all for admin user. But right now we are learning basics of Power BI, so we are more bothered about our workspace and what we are going to do with that. So we have a workspace ready, and once we have the data set here, we will be able to create report online. Now we have given in this workspace to edit the model; we will be able to edit the model also. The only thing as a pure play Power BI user which you cannot do is you can't create a data set on Power BI service. Most of the other things you can do: you can create report, you can modify report, you can edit data set, but you will not be able to create a model or add new content here. You can't create connections and bring it. So what we are going to do here, we're going to publish a report; we will also learn data set, dashboard, and app here in the Power BI service, which are basic features one must know. So let's go back to the Power BI Desktop, publish a report, come back here and see what we are able to create.
We are back on Power BI Desktop, and here we have a report where we don't have any visualization. We have just created one page because we wanted to implement the pattern of having visualization only to be used on a data set file after it has been published. This is a file which doesn't have any local database, all online database; it will not require on-premise Gateway for refresh. I'll go to the Home tab of this file and I'll press on publish. I have made sure that I have logged in using the same user which I'm using on app.power.com. So let's click on publish, and it will ask me to save if the report is not saved. And post that, it will showcase me the workspaces, my workspace available for everyone, every kind of user, even for free user; usually not used for sharing. So we should not keep a report into the my workspace which we want to share; it is for personal content, and we should avoid using the content which you want to share. So we are going to put the content into end-to-end, which is the workspace we have created for sharing. Let me click on end-to-end and click on select, and this action will publish the file. It's giving the message that it is publishing end-to-end file to Power BI, which is nothing but Power BI service, meet or collaboration. So file has been published successfully onto the Power BI service, and now we can go and check out our file on Power BI service. I clicked on got it, and let me jump onto the Power BI service quickly. On the Power BI service, I'm able to now see, after the page has refreshed, two things: one is report which is only have one page; anytime you publish a PBIX, you will get a report and the semantic model or data set. The semantic model is a new name; we usually know it by the name data model or data set. In the case of import mode, it will contain both data and meta; in case of direct query, it will only contain meta; in case of live mode, we are going to use the data set which is published already. So the report will contain the small information about the majors which we are going to create. So now we have our semantic model, and using this semantic model, we can create the report either in Power BI Desktop or on Power BI service. So first of all, what we are going to do here is we will check this semantic model, what we can do out here. If I click on that, it will open this UI for the semantic model where I have file download. This file means I will be able to download the data set; manage permissions on this data set, who can do what on this; then I can refresh, refresh now, schedule refresh history. It means if I want to refresh the data, I can refresh it from here; I can share it; I can explore this data; I can create a few visualizations here, just exploring without even creating a report. Then in the explore data, I do have option for autocreate report, create blank report, create paginated report. I can analyze in Excel by clicking on this. So if I click on this, it will create an Excel file for me, and there my data set would be attached, and using this data set, I will be able to create pivot tables and analyze it. You want to see lineage? Lineage means from where this data is coming, on which report it is going; all this is going to you are seeing this open data model button because we have allowed data model editing on the Power BI service in our workspace setting, and because of that it is showing this option. And if you click on that, it will open the data model, and you can change few things out here. You can create new major, new column, new table; you can create using the DAX formula; you can create new calculation groups; you can manage roles, manage relationship, and create new report on Power BI service; that many things you can do in the semantic model on the online version once you allow to edit it. Calculation groups has been added very recently on Power BI service. Let's go back to the UI. So these are the things which we can do. So what we are going to do is we will quickly now have a look at few of these things like creating a report here and desktop and creating a dashboard. Uh, we will avoid editing of data model; we have done a lot of work on the Power BI Desktop, and things would remain same here. We have published our file without any visualization on Power BI service, and we got a semantic. Now we would like to use that semantic model and create the visualization file, and this is going to the file which we are going to use for creating the end-user reports or dashboards. Go to the Home tab, and inside the Home tab, now you need to go and grab the Power BI semantic model. Now this connection which you are going to do with the semantic model is known as live connection. And live doesn't mean it's kind of a direct query on the database; it is as good as what you have refreshed your data set, but this particular file is neither going to on the data or not; it is going to on the model. The model is coming from the semantic; so RLS and everything is controlled at the semantic model level. So what I'm going to do here is I'm going to take this end-to-end model and going to create a report out here with the all the kind of visualization I have taught to you till now. You have to click on semantic model which you want to bring in and connect, and it will create a live connection. Once you create the live connection, you will not be able to add new table, new columns; all those are not allowed. The moment this model is loaded, you will see you only have access to the report View and model View. The access for everything else is gone; the data View and everything. You can see the model here, but if you click on any of the table, you don't see option for new column, new table, new calculation group, manage row view, role; everything is disabled; you can't do that. So you are in kind of a view-only mode for this model; it means it's the best condition to create the visualization. So what I'll do is I will create this report; I will try to have one or two pages in this one; and while I'm creating this report, you just observe; you I have already taught you all the features, how to create different kind of slicer, Pages, visualization, etc. What I have done, uh, which I realized after starting this file is that, uh, the images which I have used, uh, brand image, brand URL and image URL as columns has not worked. So I added measures for that just by taking Max of those columns, and I'm going to use them here. So I'll quietly build it, and I'll speed this up. When this video will get displayed, what you can do is you can build report of your choice, and later on those visualization can be used inside your dashboard on Power BI service. E, e, e. So what I've done is I've created a single page, and I'm going to publish this, uh, and you can create a page which you would like to have more details. Usually we will have multiple pages and communicating the message; I just created one example here, how what kind of page we can create, uh, but based on the design and requirement, you can create the page. And now what we are going to do is we are going to publish this, but before publish, it's going to ask us a name. So I'm going to save it, and I'll call it end-to-end visual file. This is visual file; you can give a name of your choice or as per your organization standard. I'm right now giving this name because I want to just differentiate that it's a visual file, and we're going to publish it to the end-to-end workspace only; we are not going to create a different workspace for this. The file is published; now we will go on Power BI service and check this file. We would also like to create a new report there, and let us see how things are different in Power BI service compared to Power BI Desktop.
I'm back on Power BI service, and let's go to end-to-end to check the newly published report, end-to-end visual. The report has opened, and as you can see in end-to-end visual report, we got our report which we have created on the dashboard; we got the slicer which we can click and filter the data. So this is the viewer View, and this is how viewer is going to use it. Remember, I am an admin; admin viewer means I have the admin privilege on this workspace. So what I'm getting in my menus could be a little bit more than what an end user is going to get here. So I'm able to filter; then same way like desktop, we can slice and dice using the visual interactions, and data will get filtered across. As I have a single page as of now, I'm not seeing the page menu, but here, once you have more than one page, you will be able to see a small arrow icon to take you to the different pages. If you click on the file, you have option save as a copy; again, I'm admin, because of which I'm getting, but viewers might not get it; depends on the permission which we are providing to them; download this file; manage permissions; print this page; embed report; generate QR code; settings; these permissions all depend on which kind of access we have given to the end user. I'm admin viewer, so I'm getting all these again; export option; analyze in Excel, PowerPoint, PDF; depending on the viewer access. Now if you go to the visual, there are these filters which are available; then there is a set alert option; then copy this as an image; again, copy this as image; if you remember, we have this option control which all users can do; and then you have this pin visual which we will be using while creating the dashboard; you have option to share on the top; you have chat in the teams; explore this data; get insights; subscribe to the report; set alerts; and edit; and as I'm having permission on this workspace to edit the report, I will be able to edit that report; and again these are some additional permissions which I can see here. Now as a viewer, you will also be able to see filter pane. Now the filter pane you will only be able to see if the filter pane is enabled; we can hide the filter pane while creating the report; then users will not see. Once user click on any of the visual, just like I've created on this tag bar visual, they will be able to see the visual level filters also. Few more things which they can do is view; they can view as a full-screen escape and come back; then they have this fit to page, fit to width, and actual size; all these options they can also explore; then there's a comment; users can give give a comment out here; you can click on got it, and then you can start writing down the comments; this is for the collaboration; we close the comments; then you have this mark as a favorite; if you click on this, this report will be marked as favorite. So what I'm going to do here is I'm going to click on edit, and I will try to modify this report. What I'm going to do here is I'm going to create a little bit of space, and for that I'm going to delete this card Visual, and also let me do one thing; I'm going to make this slicer as a normal button slicer. So I'll create it as this kind of a slicer, and then I'll go ahead and go to the slicer setting, and I'll create it as tiles. Now with these changes, let me go ahead and further do more changes in this report in the edit mode and showcase you what all we can do in the edit mode. I can even modify the model because of my setting; I can add a new page and create additional visualization here. So let's I can plus a a page, and I can call it as detailed page, and I can add additional visual to that page. Let's say I want to add a trend; I can bring in month, year here, and I can bring net, and then can I can convert this into a line visual; I can add additional visuals here; so so here I have added a page; in this manner you can edit a report on Power BI service, and you can save it. Now there are various options in a Power BI service report. So if you go to the file, you can save, save as new copy, print; if you want to print the current batch; you want to embed this, then you can generate embed code; this is the embedded code which you can use; then embed in SharePoint Online; you can get the code for embed SharePoint Online; publish to web; now publish to web is a permission which we need to give, and once we give this content would be available publicly. Now my content is basically learning content, so I can publish it to web, but your organizational content you should not publish it to web; you should instead use uh the other secure ined method; export to PowerPoint; you can export it to PowerPoint with the current value or with the default values; two options; exclude hidden Pages; only export current pages; and in that manner you can export it to PowerPoint; it will generate a PowerPoint, and you will be able to use it; also in PowerPoint we have a connector for Power BI which can be used to connect with the pages of the Power BI report live; then export to PDF; and download this file means it will download PBIX; in the view we have fit to page, fit to width, actual width, and all these options uh we can see different page like if the selection pane is not coming, I can see that; if the bookmark pane is not coming, I can use that; if the SN slicer pane is not coming, I can enable that; insides pane I can enable that; so all these things I can enable; right now I'm disabling those; reading view; we will come out of the edit view; let's
Go back to the Edit View and then open Data Model. Then you have options for Ask a question, Data drill, Text box. You can add shapes. You can save this report and chat in Teams and generate a QR code. Analyze in Excel: you can download and analyze this report in Excel. These things you can do now.
Let's go back to the reading mode and check out more options. Let me give you a quick recap of the menu items we have here. So the File options now has: Save a copy, Download this file, Manage permissions, Embed report, QR code, and Settings. So these are the settings for the report: the report name, the description. If you want to promote endorsement, if you want to promote this report to the users, you can use that, and there are a few other options which you can use. Export, Analyze in Excel, PowerPoint. We have already checked out PDF. You can share this report with the other users. I can assign it to the other users in the organization. I can share the link, mail, or Teams, or PowerPoint. I can chat with the other users regarding this report in Teams. I can further explore this data by opening the Explore data. I can get inside, subscribe to the report. I can create a subscription for this report to come to me on a given time. I'm discarding that. I can set an alert. An alert can be set on a major for a value, high or low, so threshold greater than or less than, on which major I need that, what kind of notification I need, and I can start my alerts once that setup is done.
And then we have: C related, contain lineage view—means from where this report is coming. Pin to a dashboard. So pin a dashboard here will pin the complete page on the dashboard. On the individual visuals, we do have an option to pin them to the dashboard that we can use to pin the individual visual on the dashboard. Other than that, we have the option View semantic model, which we have already seen. It will open the semantic model, and then there we can go ahead and open the semantic model again. So, means this is going to lead us to the first screen of the semantic model. Then there is an Open semantic model. After that, we can go ahead and edit that, and as you have seen, we have enabled the option to edit it in the Power BI service, so we'll be able to edit that now. Other than that, in case your organization has the F64 capacity onwards or P1 capacity onwards, you will be able to use this co-pilot option to ask various questions, both in the viewer mode as well as in the edit mode. And then you have the bookmarks option. You can add the personal bookmarks, or you can click on the Show more bookmarks to see what all already existing bookmarks are there.
So now what I've done is I've covered basically most of the options which you have in the Power BI service report, in the edit mode as well as the viewer mode. So you have to go ahead and explore all these options. These options keep on changing, and they keep on increasing also as and when we get new features. So continue to look towards what features are available onto the release which is available at that particular moment of time.
Now I would like to create a dashboard. A dashboard can only be created on Power BI service. Remember, a Power BI report which we created on the desktop is not the dashboard in Power BI World. A dashboard is something which we create on Power BI service, and to do that, what I'm going to do is I'm going to open my report which I have recently published, and in that one I have pin icons, and using those pin icons I'm going to create my dashboard. Remember, a Power BI dashboard cannot have slicers unless we pin the complete page. So once we pin the complete page, then only we will have the slicers. Individual visuals will not have slicers. We cannot pin the slicer, and even if we pin the complete page, the slicer with that page is going to impact the section in the dashboard which is coming from that page, not the other visualization. So remember these differences between Power BI service report and dashboard, and take a call whether you really want to create a dashboard or you want to create a report.
I'm back on Power BI service, and let's go to end-to-end to check the report has opened. Let me go to the detailed page, and as you remember, we have these three dots. On three dots, we have this option: Pin to a dashboard. That can pin the complete page to the dashboard, including the slicers. Remember, when in Power BI service dashboard you cannot add slicers. So if you go to the individual visuals, if I go to here on the main page, if I go to this visual, you don't see a pin icon, but in this one you see a Pin visual. So Pin visual will add it to the Power BI dashboard, but a Power BI dashboard cannot have slicers. You can't pin the slicers. So if you want the slicers, you have to pin the complete page. So in this manner, you can pin the visuals to a dashboard and create a Power BI service dashboard. You can pin the visuals from multiple reports on a Power BI service dashboard, and you can use that. And instead of pinning individual visuals from the first page, I'll pin the complete dashboard, and let me give this dashboard a new name: Main Dash Pin Live. So I have pinned this. It's giving me a Go to dashboard option, but I would like to pin a visual, and then we will go there. Then I go to the detailed report, and from there I'm going to pin this line visual, Main Dash, as well as I'll pin this P visual, Main Dash, and now I'll go to the dashboard. Now when I click and go to the dashboard, you can see that I have my page as well as my two visuals which are coming here. I can change a little bit of layout if I want. Then I can ask certain questions here within Q&A. It will generate the Q&A. I can ask: Top customers by Citys Nets, and it will generate a visual. So that is the advantage of giving a dashboard to the end user, that they can ask questions, and using those questions they can get additional answers. If I want to edit this dashboard, I can edit. I can subscribe to this dashboard. I can chat. I can comment on this dashboard by adding additional comments here. I can click on any of the visuals and analyze the data. Now because I brought a complete page, it is doing the interactions also. Now in the case of the single visual, the moment I click on that visual, it will take me back to my report.
Let's look at the Edit mode. You can add the tile, dashboard theme, mobile layout. These things you can do with the dashboard. Now, Subscribe to dashboard. I can create a subscription for a dashboard to deliver to me at a particular time. And on the right-hand side, if you pay attention, whatever reports and dashboards we have open, you're getting the icon for that, and you can close it. So I close the dashboard. My report is open. I can close my report. My data set details is open. I can close those data set details.
Once you are done with this entire exercise of, you know, creating a Power BI report and dashboard and everything, the next thing which you need to do is schedule your data refresh. Now to schedule your data refresh, what you have to do is you have to go to the settings of your semantic model, and then there you have options for scheduling the refresh. The semantic model is available in your workspace, and using the three dots you can go to the settings, and there, from there you will be able to schedule the refresh. Also, in case you are using the on-premise data, then there is an option to configure your on-premise Gateway settings and connection settings. You can edit as per requirement inside the semantic model settings only.
Let's jump onto the workspace once again and try to refresh the data set and see what all things we can do. In my case, I have online data, so I would not require an on-premise Gateway. Simply refresh should be able to refresh my data, and also I can schedule it. In my case, because the data is static, there is no benefit of scheduling it, but in a real-time scenario you have to schedule a refresh. Now, in case of Pro, you can get refresh as many as eight times in a day. In case of PPU and Premium, you will be able to schedule refresh 48 times in a day. If, if you want near real-time data, then you have to choose for direct query mode. I can go back to my workspace, which is already open, and here what you can do, because it's an online version, I can actually refresh my data set to bring in the data. Schedule refresh has been disabled. Refresh as failed. Let's look why it's failed. So first of all, let's go to the settings and check out everything is fine here. So I go to the setting here. When I scroll down and go to data set setting, there is an error here. Edit credentials, and we will use anonymous organizational, and we'll say Sign in. Let's see does it work out. Yes, it has worked. Now let's go back again and see do we require a permission, or this time it's going to refresh. It's refreshing right now, if you see. And to check the refresh history, you can go to the settings again, three-dot settings, refresh history. It will show you the refresh is in progress, and once it is refreshed it will give you a message that refresh is completed. And the refresh has completed while we were checking that out, and new data has come. So in this manner you can refresh the data, but before you refresh the data, what you have to do is, because I was only having up one data source and my data source was an online data source, it does not require a Gateway. Otherwise you have to configure an on-premise Gateway. Right now it is a cloud connection, but you might have to configure an on-premise Gateway if you're using on-premise sources. Once you configure your on-premise Gateway, you have to configure your data source credentials. After doing that, if there are certain parameters required, M query parameter if you used, we can to set those query caching, in case you want, so you can turn on the query caching. Refresh. This is the scheduled refresh. I can schedule it to refresh daily on a particular time. So once I click on on, I need to add a time, and then I can apply, and now it will get refreshed daily at 1:00 a.m. Right now I'm disabling it because I don't want it to happen. Server settings. This is my server data connections. Then Q&A features. All these are data settings which we can change. Let me go back to my by workspace. So now you know how to refresh your data set also. Now whatever Gateway and connections we have, where do we monitor those? So in the setting icon you can go to Manage gateways and connection, and here you will be able to see all your connections. Under the connection, if you have set up an on-premise Gateway, you will be able to see an on-premise Gateway. In the past I have set up an on-premise Gateway that you are seeing. If there are virtual Network gateways, you will be able to see it here. So in this manner you will be able to see your connection details and Gateway.
Now let's quickly understand how can we create a altogether new report on Power BI service using a data set. So there is an option on the Home tab, or there is a Create button here on the left-hand side top. Once you click, you can paste data manually, or you can pick up a published data set. I'll pick up a published data set. End-to-end autocreate report or create a report from blank. You can use autocreate report, and Power BI will create a report for you. I'll create a blank report just to explain it to you, and I am on the very similar UI what I saw in the edit report. Now here I can quickly create a visual. I'll just go to create one visual for giving an example. I have created a visual, and now I can save it. So when I save it for the first time, it will ask me a name, and let, let me call it Service report, and click on Save. The moment I save it for the first time, it will take me to the reading mode. After that, when I go to the edit mode and now save it, it will remain in the edit mode. So in this manner you can edit your reports or create a new report on the Power BI service.
Service, we have a version of Power Query online where we can actually transform our data centrally. That is known as Data flow. Now the reason why we have Data flow here on the Power BI services, basically what happens, sometimes multiple teams use similar kinds of Power Query transformations, and that is why we want to centralize those transformations. That is why on Power BI service we can create Data flow. Data flow can centralize all these transformations. In the Fabric world we also call it Data flow Gen 1. Now Data flows are for data prep, data cleaning, and data transformation. You can use Data flow just like you use Power Query on the desktop. Once you do the transformation, you can use it as a source on Power BI desktop to create your new report. In an ideal world, we will create a Data flow for our Dimensions where we need a lot of transformation, or a small table where we need, need a lot of transformation. We can centralize all those transformations in the Data flow. So we can have a dimension in the Data flow, then we will use this Data flow along with our facts directly coming from the sources into a data set. We will publish that data set which is a Power BI desktop file. We'll publish that data set without creating a visualization, and once that data set is published, we'll use it again and would create a visual file. I'll just go to give you how do you create a data set. So press New and Data set. You will be landed on Power BI Data set. Here you can define a new table, link table from other data flows, import mode—means you can import a model, attach common data model folder. Okay, so I'll use this Add a new table. It will lead me to the UI to bring in the data, and here I will use this Web API. In the Web API I will bring in my data from GitHub. So let me go to the GitHub and bring in my file. Says Data used in video. I click on that, right-click on Raw, copy link, go back to the Power BI service, give this URL. I have already used it, so it is not asking for any further details. Press Next, and I can add all of them, and then I can click on Transform data. It, it will add the data to the Power BI data flow, and here I can do the transformation, clean data, prep, everything. Now if you remember in the Sales table I added some column index. The same columns could have been added to the Power BI data flow or Power Query also. I can go here and can use Add column and can add a custom column. Let's call it Gross, and Gross is nothing but Quantity multiply by Price, and I can give it as a data type decimal number. Okay. In the same manner I can use other columns, and then I will be able to complete my transformation. Once I'm done with all my transformations, I can go ahead and use Save and close to save the all the data in my data flow. It's going to check, and it will ask for a name. I will call it Sales data flow, and I'll give the same description. I'll save it. How it is really important that the data flow by default doesn't load data, so the very first time you need to refresh it now. So you have to click Refresh now. Now typically on D Gen 2, which is on Microsoft Fabric, Auto refresh kicks off immediately after publish, but this doesn't happen in Data flow Gen 1. We have to manually kick it on. Every time you do changes, you need to do a refresh. You can close it, and when you come here on your workspace, you should be able to see this data flow, and you can go to the refresh history to check if the data is loaded or not. In our case the data is already loaded here. Now what we need to do is we need to go to the Power BI desktop and use this data flow. So I'll open up a new file on Power BI desktop. I'll open a new file. The new file is opened, and here now I want to bring in data from Power BI data flow. So I'll use Get data, More, and there I need to go to Data flow. I can search for that. I got options for Data flow, Power BI data flow, Legacy data flows. So they are coming from different, different places. So let's use Power BI data flow, Legacy, and use Connect. Let me try to sign in. Let me use Connect, and in the end-to-end I'm able to get my data flow from here. I can pick up all the four tables and load the data from here. I have to do all the steps which I've done during this exercise, creating the model, measures, all the calculations, field parameters, calculation group, etc., and then finally publish this, and once I publish this file I'll get a data set, and I can use that data set again to create my visualization. As you are already aware of all those steps, you can try that out. I will simply share it as a new end-to-end file. In this manner you can use Power BI data flow to centralize all your transformation, data preparation, and data cleaning.
In Power BI workspace we have Apps. This App has a really important role when we want to share the content with the users and we don't want to give these workspaces kind of a look to them. So what we typically prefer is we give them an App access. So what we're going to do is we are going to use this Create app, and we can give it as a name, let's say BI App. Can give a description. We can choose a color for our app, and, and we can upload a logo for that. Then we can go to the content and add a Content. So we can add the reports which we have: end-to-end and Service report. Okay, all these reports we can add. Multiple reports we have, so we can add those reports. Now inside each report, if there are multiple pages, it's going to show those pages, and we can see those pages. So we have multiple content which is now, how do you differentiate content for different people? So when you go to the audience, actually you have these show/hide buttons. Using these show/hide buttons you can create different kinds of audiences. So you can say New audience. You created a new audience. Now see this is BI App. This is New audience. Now this New audience I can refer as, let's say, Service only. I want to give a Service report, so I'll give a Service report to that audience, and I can hide other things. Let's say I can hide these. Only will have Service report. Then I can give the users who will be audience of Service report. In Power BI App I can give the audience who will be audience of BI App. If you want to give it to the entire organization, you can choose the entire organization, but there's no benefit of creating multiple audiences if you are giving this report to the entire organization. Now there are advanced options like: Allow people to share the data set in this app audience, Allow people to build the content with this data set in the app audience. So you can give those permissions as per requirement. Usually what we do is we assign it to users or to the emailed enabled list, and then finally after we decide our audience, decide the reports. So in this workspace I can have n number of reports. Out of those reports I can decide which I want to add in App, and out of those reports I can decide which reports will go to which audience. So once I'm done with that, I can publish this app, and this will be shared with users. In the content I can add some headers, sections, and all those. I can divide these reports inside the category and all those I can do. So I can create different sections also. So let me finally publish this app, and it will be published. It will show a URL which you can copy, or you can click on Go to app. You can share this URL with the users, and this will now open Power BI Service app, and you can see with the chosen color we are seeing the app, and this is the better way to give it to the end users. They can have access to multiple reports at...
One place and we don't have to share each and every report. They have very similar options what we had in the Power BI service, so they have print this page, embed report, QR code, share, export, and remember all these are controlled from the permission what we have given at the tenant level. So in this manner, you can create and share an app.
If you remember when we were analyzing the data on Power BI service, we have downloaded one Excel for analyzing. Ex. Ex. This is the same Excel I have opened up and also enabled the content, and I'm getting now all my data which I can analyze here. And here also I can create a pivot table. You can already see there is enablement of pivot table. So I can go here and choose certain things. Let's say I can bring in brand on the row, and then I can bring in certain majors for analysis, and I can start my analysis in this manner.
If you are an Excel user, you still like to be an Excel user, but you don't want to, you know, download the data and analyze it, you can simply connect to this data set. You need to have permission to for that, and once you have permission you can do that. It is not that you can always have to do analyze in Excel. You can go to the data and in the versions depending on what version you have inside the get data, you do have option to connect Power Platform, and there you can connect with Power BI and you can again create similar kind of visualization. So you can initiate process from here also.
So now I can save this and keep it. Another thing which we have done is we have downloaded this PowerPoint. So as you can see this PowerPoint has been downloaded; it has been created as an image. So what we can do here is we can add a new content and try to use the Power BI plugin. So we have a Power BI plugin to connect live and get the data from Power BI directly. So I'll add a new slide here, a new blank slide, and inside that new slide let me add this Power BI plugin. In the newer version which is by default available, in the older version you can go ahead and add it from the adding. Now it needs a URL. To get this URL I need to go to the Power BI service report, and in the Power BI service report this is the report I have which is right now open. So I can go to share, copy link, copy this link, come back and paste it inside our PowerPoint, click on insert, and this is inserted now into the PowerPoint. And if you go here in the data option, you have the refresh option, you can get the new data. You have the Data Insights, you have filter section, you can filter the data, you can hide the filter section, you can enable the filter section. There are few more options like clear data, learn, then outline. All these options are available. So basically you can connect live; you don't need images now. When I downloaded it, it came with images. Now I can have a PowerPoint with the live connection, and in that one I can embed my visualization, and I don't need to go back to Power BI service while doing the presentation itself. I can slice and dice the data.
So let's look at this first page. Now it is a static image; I can't slice and dice, isn't it? But if I go ahead and add this page, let me bring in that particular page. So close this, go to the main page, share, copy link, copy, copy this, let's go back to the PowerPoint, add the Power BI plugin, give it a space, paste this URL, insert, and now I have my page. Is it working? Look at this. I'm analyzing data here on PowerPoint. I'm no more going back to Power BI. I can go here, filter the data here. The data is reflecting, changing based on interactions. I can go here and select States whatever I like, and the data will keep on filtering. So in this manner I can have a dynamic slide on on my PowerPoint, and I can analyze the data directly from Power BI service page which is embedded here. And to give more space you can hide the filters as I shown you; you don't need that section. What happens when you're doing the presentation? You have a lot of content, but your Power BI content is static. Now you can make that content dynamic by using this Power BI plug-in in PowerPoint. Instead of downloading this static image, you can use this and create dynamic slides on PowerPoint.
Friends, you have reached to the end of this video. You have covered 20 hours of detailed video along with me in learn Power BI full course. I'm hopeful this video would have enhanced your Power BI knowledge to the next level, and now you are a pro in Power BI. Power BI is a journey; it's just a beginning. Friends, this is just a beginning. With this video you are now appr pro Power BI professional. To become expert, take full advantage of 600 another videos on my channel. Also go to community.powerbi.com and try to solve some of the problems. By solving community problem and providing solution is the best way to take your Power BI journey to the next level. This is the same thing I have done for years. Serving community will help you in deep understanding of the Power BI concept and will help you to solve real-time problems. There would be no lack of real-time problems once you reach to Power BI community. So friends, I would like to thank you for your patience of watching this 20-hour video. Please like, share and comment on this video. Share it with your friends and relatives and anyone who is looking to start the Power BI journey. Thank you. Have a wonderful 2025.