Skip to main content

Power BI: Understand Filter Context and CALCULATE

 Whether you are new to Power BI or have been using it for a while, filter context for visualizations and measures are so important to understand.  I will admit it took me a while as someone brand new to Power BI and data modeling to wrap my head around it.  With some practice and learning from others, things finally clicked for me.  So for this week’s video, I wanted to showcase to you the basics of filter context.  After understanding how filter context worked, I then realized that sometimes I didn’t want the current filter context or I wanted to modify it to show values that were important to me.  This then led me down the rabbit hole of the CALCULATE function in DAX.   Wow!  I did not even know how powerful the CALCULATE function is in terms of modifying filter context.

 

Check out this week’s video for an explanation of filter context and then how you can modify it using the CALCULATE function.  I also showcase three other functions that are often used with CALCULATE which are ALL, ALLSELECTED, and ALLEXCEPT.

 


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