Skip to main content

Analyse Data by using Role-Playing Dimensions Effectively in Power BI

Role-playing dimensions are one of the key concepts in Data Warehousing and Business Intelligence development. If you are not familiar with it you can read James Serra's Blog article on Role-Playing Dimensions from here

In this article, I'm going to demonstrate to you How to Analyse Measures by using Role-Playing Dimensions Effective manner. If you are familiar with Relationships in Power BI you know by now, you cannot create two active relationships simultaneously with the same tables in a Power BI model. You must make one relationship Active while other relationship's inactive. 



For this Demo, I've taken the WideWorldImportersDW demo database. So you can download it from here for free. For simplicity, I only have taken the Sales and Date table and imported it into Power BI. 



You can see in this data model we have a Sales transaction fact table and Date dimension table. If you looked closely the Sales table contains two Date columns, Invoice Date and Delivery Date. But, in theory, we cannot have both relationships as active. This means only one relationship filter can apply in your report. In this case, I can only visualize the Sales data using the Invoice Date. Because it is the active relationship in this model. Even the relationship exists for the Delivery Date, since it is inactive we cannot use it for visualization. 

So, in this model, Date table working as a role-playing dimension. At a time it plays the Invoice Date role. In another time the role of the Delivery Date

In this model, I created a Calculated Measure for Quantity and named it as Invoiced Qty. Because, in the model, we have made Invoice Date as Active relationship. 

Invoiced Qty = SUM(Sale[Quantity])

At any given time the end-user can visualize the Quantity with Invoice Date as below. 



Then Why is an Inactive Relationship?

Though you cannot use inactive relationship filters straight away, you can use them Programmatically. This means Power BI allows us to create Calculations by making use of them. I'm going to create another Measure called Delivered Qty by referring the relationship Sales[Delivery Date] ---- Date[Date]



Delivered Qty = CALCULATE([Invoiced Qty], USERELATIONSHIP(Sale[Delivery Date Key], 'Date'[Date]) )

Let's visualize them both and see what are the differences. By looking at both visuals, at a glance you would not see much difference. But, in fact, there are references in figures. Because both measures calculating the Item Qty respective to Date.  



If you put both Measures and visualize, you may see a slight difference like this. 



Let's Improve the End-user Experience 

Now, we know how to use role-playing dimensions by creating DAX measures. What if we can make this more usable. How about a Slicer? If we can create a slicer or a Switch to toggle between and each role, this will be an awesome experience for the end-user. Here is how to do it. 

1. Create a Table by Entering Roles (Filter values) 

In this step, use the Enter Data feature to key the values you need to be a toggle in the visual. I'll make this table hide for report users. 

 
2. Create a calculated Measure to get the Selected filter value. I did not want to make my final Measure too complex. So I break it into small pieces. This is to make it more clear. You know what I mean 😉




Selected Role = SELECTEDVALUE('Date Role'[Analyzed By]) 
  
3. The final step, create a Calculated Measure for Quantity using the Selected Role measure we created in step 2. We need to show the Quantity value, either Invoiced Qty or Delivered Qty based on the selection. 

 







Total Qty = IF([Selected Role] = "Invoiced", [Invoiced Qty], [Delivered Qty])

Finally, you can give a rich analysis experience to the end-user by combining features offered by Power BI. 



Hope you learn how to analyze data with role-playing dimensions simultaniously. You can download the Power BI Demo pbix file from here

Comments

  1. This comment has been removed by the author.

    ReplyDelete
  2. I feel Power BI is the most complex and useful tool to create the dashboards and produce reports for end users.

    Powerbi Read Rest

    ReplyDelete
  3. You finished certain solid focuses there. I did a pursuit regarding the matter and discovered almost all people will concur with your blog.

    360DigiTMG

    ReplyDelete
  4. There is plainly a ton to consider this. Keep working, remarkable work!
    360DigiTMG data science course

    ReplyDelete
  5. Set aside my effort to peruse all the remarks, however I truly delighted in the article. It's consistently pleasant when you can not exclusively be educated, yet in addition, engaged!
    difference between analysis and analytics

    ReplyDelete
  6. I will truly value the essayist's decision for picking this magnificent article fitting to my matter.Here is profound depiction about the article matter which helped me more.
    data science training in noida

    ReplyDelete
  7. Informative content. Thanks for sharing information.
    big data training london

    ReplyDelete
  8. This comment has been removed by the author.

    ReplyDelete

Post a Comment

Popular posts from this blog

How to Add My Power BI Report in My PowerPoint Presentation?

Had a great week after conducting two-day sessions on Data Warehousing and How to do Business Intelligence with Microsoft Power BI . During the sessions, I got an interesting question from the audience. The question was “how its possible to show the Power BI report or visuals in my Powerpoint slides, at the same time the data need to be up-to-date same as in report”. I love these sort of questions and find solutions because these are real-world problems they have. I thought to write a simple post to address that problem, and in this post, I explain how to achieve it. Pre-requisites You have already Power BI report created and published to the Power BI service. If you missed how to do it read this blog . If your source is a file like Excel or CSV the deployment is even simple. You don't want to worry about to configure the gateway and you can simply click Publish and publish your report. Steps to Follow Open the MS PowerPoint and go to Insert tab and My-Addins It will ...

Get Started with Azure Machine Learning

Azure Machine Learning is a Microsoft cloud solution which allow us to do end-to-end experiments using the samples, experiments provided. Further, it allows us to write custom algorithms using popular data science languages like R and Python.  Lets start to create preview account on Azure and create Azure Machine Learning Experiment workspace. Microsoft gives 30 days trial period for free to do experiments on Azure. You can start to create an Azure account from here. When you sign-up you might need to provide credit card details that only for validate the user. As far as I know we only need to pay if we are going to upgrade the free subscription for Pay-as-you-go model. Lets start to create a machine learning experimentation. For that click on left down below "More services" and from the search bar, type "Machine Learning". Then click the Machine Learning Experimentation in order to create new environment. Then it will open new blades to provide d...

How to Resume Azure SQL Serverless Database Manually?

Problem It was a horrible experience with a busy day. Suddenly the Developer Database, presumably Azure SQL Serverless Database went off. In another word, it was in Auto-pause mode.  When I search through the internet, I couldn't find any reliable method of turn it back to accessible or resume mode. According to the documentation , If I login to the database then it should be turned it back, but it is not the case. I tried with both Management Studio and Azure Data Studio those options were not in my favor. Solution Unfortunately, the solution is pending. Unless you have to trigger manually by doing one of the tasks was in the list I've referenced above. I found that this feature is started to develop, according to the Microsoft Azure forum . But, that is not helpful to get sorted my issue today. Workaround  Maybe if you are an Application developer you might not get this issue. Perhaps if you invoke some function which hit to the database, this problem wi...