Skip to main content

Power BI: DAX Function USERELATIONSHIP Explained

In the Power BI Desktop, you are allowed only 1 active relationship between tables in your data model.  Many times this is all that is needed.  There are, however, scenarios where this becomes a huge reporting issue.  For example, what if you have a table of sales where one column contains the date a sale occurs and another column that records the date the money from the sale is collected.  Well, depending upon which relationship is active with your Date table in your model the sum of your sales will either be based on the sale date or the money collected date.  If you need to see both values though this is where you need to make a separate measure using the function USERELATIONSHIP paired with the function CALCULATE.  The USERELATIONSHIP function will allow you to access inactive relationships in your data model. 

 

Another scenario, where I have seen this be an issue, is when users need to see their sales based on the city where the sale occurred compared to the city where the sales are being shipped.  Here again, we run into an issue of only being able to have one active relationship from our sales table to our Geography table.  If you have ever run into an issue like this check out this video explaining how to make inactive relationships and leverage the USERELATIONSHIP DAX function.





Comments

Popular posts from this blog

Pizza and DAX are my Love Languages

Okay, okay, not really. Beer is though. But if my wife asks, it's "quality time spent with her watching British dramas on PBS Masterpiece." In all seriousness, if you are new to Power BI - then DAX may seem like a foreign language.  Do you want to find out some quick tips or best practices?  Well, let me give you a few tips that were helpful to me when first starting to write DAX formulas. The TAB key is your best friend.   Don’t try to type everything character for character for your formulas.   Just type until you the formula, column, table, etc. shows up directly under the formula bar.   Once, it is there hit the tab button and it automatically promotes it into your formula bar.  Is the formula text too small for you?   It’s always too small for me when doing demonstrations for others.   Place your cursor in the formula bar.   Hold down the control key on your keyboard and use your mouse scroll wheel to make the text larger or smaller. Would you like to move to a new l

Loading Folders as Data Sources in POWER BI

  Power BI can connect to a plethora of different data sources.   Did you know Power BI can also make loading multiple files at one time a cinch?   There is an option from the Get Data icon for “Folder”.   Wait, a folder is not a data source, is it?   Well, all the files in that folder are for sure data sources. So what makes the “Folder” option something you need to know about?   Do you get new files with the same column structure sent to you on a set time frame and then have to go and append them to your existing file?   Have you ever found yourself appending multiple files over and over that have the same column structure?   If you answered yes to any of those last 2 questions, then you are going to fall in love with the “Folder” data source. Simply put, the “Folder” option allows you to bring in all of your files at once into Power BI.   You will then make all of your transforms on one sample file and Power BI will automate the process across all the files of your choosing and

Remove Duplicates And Keep Most Recent Records in Power BI

  A week ago in my last training, I was demonstrating how to get rid of duplicate records when making a dimension table.   One of the people in attendance asked is there a way to get rid of duplicates but keep the most recent duplicate record based on a date column.   I thought, “Of Course!”.   All we need to do is use the Query editor, do a sort on the date column, and then get rid of duplicates.   Unbeknownst to me, it didn’t work.   It kept the oldest record and not the newest.    The reason being after doing some research is that the Power Query editor will make determinations if it can do some of your steps in a different order and still give you the same result while producing the quickest data load.   Normally, that is what an ideal Power BI user wants, but in this case, we need the sort to happen before the remove duplicates step.   Thus, after research comes in the function Table.Buffer to modify our sort code.    Take a look at my video for a further explanation and demonstra