A common problem many users face it the fact that there are multiple date fields in their tables, and when they want to use a date dimension, Power BI only allows for on active relationship between the two tables.
For example, I have a dimension table from my leasing software that included information on each lease including the commencement date of the lease and the expiration date of the lease. In Power BI when I use a separate date dimension (which I always recommend for many different reasons), I can only link the dimension table to date table with one active relationship. See screen shot below.
Since most of my visualizations will be based on the Commencement Date, I will make that the active relationship. However, I would like to create a visualization showing my leases by expiration date. In order to do this, I have a couple options.
1. I could create a second date dimension table in my model. This is fairly simple. I would just copy the first dimension and give it a new name (Expiration Date). I would relate the Lease Details table to the Expiration Date table using the expiration date. The drawback to this is if you are using date slicers on the report, you would need two different date slicers since they are different tables. This can also quickly get out of control if there are numerous dates.
2. I could use the DAX function USERELATIONSHIP.
The function returns no value; the function only enables the indicated relationship for the duration of the calculation.
By using this function I can create a new measure to count my leases based on their expiration date.
Expiring Leases = CALCULATE(DISTINCTCOUNT('Lease Details'[Lease]),USERELATIONSHIP('Lease Details'[ExpirationDate],'Date'[Date]))
Once this measure is in place, I can create my two different visualization using the same date dimension.
For more information on USERELATIONSHIP go to https://msdn.microsoft.com/en-us/query-bi/dax/userelationship-function-dax
Popular posts from this blog
There are many different articles available on Time Intelligence in Power BI. Many new users to Power BI do not really understand the importance of having a date table in their data model. I have spoken on this topic on many different occasions and continue to receive a lot of questions about the topic. In this article I am going to try and cover a few tips on how to work with dates in your Power BI model. Many new users simply use the Auto Date & Time function of Power BI. This function automatically creates a hidden date table for each field in the model with a date or date/time data type. This function is enabled by default and it allows for slicing by Year, Quarter, Month and Day. The problem with Auto Date and Time is that it only works with a standard calendar (Jan to Dec). It requires a datetime column in the fact table. It does not work with multiple fact tables and it does not support time intelligence calculations (YTD, MTD, etc.). So there must be
When working with financial and sales data, clients often ask for charts showing the last 12 months of data. This is actually very simple using relative date filtering. In addition, they might ask to compare to the same month last year. With a simple DAX calculation (SAMEPERIODLASTYEAR) it is possible to add this measure. Here is the formula: Same Month Last Year = CALCULATE(Sum(Sales[SalesAmount]),SAMEPERIODLASTYEAR('Date'[Datekey])) For many users this is all they need. The chart will update each month and they will always be able to see the last 12 months. However, this chart will not work with date slicers. If the client adds a date slicer to the page and selects just one month, the chart will be limited to one month. The reason the chart is limited to one month is because the date dimension relates to the sales fact table and it filters the data for the selected month. However, this is not what
Have you ever wanted to just create your Dynamics 365 Finance journal entries in Excel, without dealing with the Excel Add In. This blog article will show you have using Excel, OneDrive and Power Automate. Typically I put all the steps right in the article, but this is a pretty detailed process, so I have included the link to a document I prepared, or you can simply watch the video below. Download the detail directions here