hi everyone in this video we are going to go over the topic of parameters
in power bi parameters for some reason in power bi are not as intuitive as you might expect
so hopefully by the end of this video you'll have a better understanding of how they work
and how you can use them on your dashboards
i'm assuming that you're familiar with the concept of a parameter usually you'll pass
this into a query to filter your data set or do some other custom logic with it if you remember
in previous videos we talked about filters and oftentimes these two
can get switched up or confused and the way i like to think about it is a filter
is something that happens after a data set has already been returned
whereas a parameter is actually limiting your data set before it gets to you so again a filter
the data set has already been returned and you're just filtering on what has been returned
whereas a parameter is actually dictating what gets returned in that data set to begin with
there are two ways you can go about adding parameters to your report and
the first one we'll look at is on your main page here to add a parameter this way it's
actually pretty straightforward go over to the modeling tab here and to select new parameter
and here you'll get some basic options you'll get name data type it'll ask you for a minimum value
a maximum value as well as how you want it to increment so do you want it to go from 0 to 20
by 1 2 3 5 whatever and a default value it also gives you the option to add this parameter as a
slicer to your page if you want to power bi understands that oftentimes that's how your
users are going to want to interact with it there it should be something that's easy to work with so
you have this option to add it if you want and we will add it just to show you how that works
and let's give this a name and click ok now we can see it got added here the bottom left on our
current page so let's move this up here and if we move this here we can see this value is changing
and another thing to point out here if we look at fields we can see this was actually added
as a new data set price parameter and there's two options we have we have the price parameter
value here second and then the name of it i've selected this and you can see up here in the
in the formula bar it essentially just creates a little dax query for you to create this parameter
and in this case we're just generating a series 0 to 20 incrementing by 1. to show
you what this one means here i'm going to add a card and the field on the card will be the value
of the parameter and here we can see it's going to reflect what we have here put them next to
each other so it's easier this is based on the name and this is based on the value so you can
use them interchangeably to make it a little easier for your users to see
what's going on but currently nothing's actually happening with this parameter we're
not using it to do anything it's just you know displaying a value to us so how would we use it
what we could do here is just create a brand new measure that will give us some sort of
value based on the parameter so it's almost like you're inserting it into a query but in this case
we'll use it in a dax function within internet sales here i'm going to select new measure seeing
that we have an order quantity column here this is just summing the order quantity value
what we could do here is create a similar measure by instituting this parameter within it
i've just copied this dax query in here for the sake of time and essentially what this is doing
is first filtering the internet sales model that we have here and it's going to
sum up the order quantity just like we do here but now that we're using this filter function
here we need to give it something to filter by and what we could do here is use the parameter
so to do that if i start typing out parameter it's going to recognize the name of this we called it
price parameter and it's selectable in your dax query so we can put this in here now right now
we're getting no values because we're saying where the price is less than the parameter so there
are no bikes and because we're filtered on bikes there are no bikes less than twenty dollars let's
let's un filter and now we can see we're getting some values
because while this one is looking at everything this is using that parameter to filter it
only look at results where that filter is is true and that filter is based on our parameter
and that's one way to use a parameter in a dax query and make it visible for users as well but
let's actually add something that would filter the actual data set itself and how would you do that
let's go through and edit queries now right off the bat here we can see
there's an option here for manage parameters and let's select new parameter and we can add
a new name and you'll see this is new this is not the same as what we just worked with this
is going to filter the actual data before it ever comes into your models itself it will be added as
a transform step over here let's call this one color here there are many more options we'll say
this is a text there are three options for the suggested values and we'll go through all three
first is any value meaning you could just insert whatever you want a list of values you'll be able
to actually give a hard-coded list right here in power bi and then a query is going to be based on
some other file or sql statement that you return essentially some other data set to
start we'll do any value and let's just say black select ok now we can see this came up here as a
another query over here just for color this is where it's going to hold that parameter
and to use it let's go to product we select filter let's just say equals
and here just you could hard code something in here and say whatever you want but the other
option here is to filter by a parameter and now we could have added it new from here but let's say
parameter and we only have one option but this is where you can use that as well let's select ok and
now this whole data set is filtered by just color and again it's similar to a filter that you would
do you know on this over here but instead we're actually filtering the data before it ever gets
there so this would apply as a transform before it ever gets to your report to even be filtered
now let's add a new one let's do let's do a list we'll call this one first name we'll go again with
text in this case we'll say list of values and we can put john michael jennifer i don't
hopefully these are options and lisa default it now recognizes that this is a list so your
default value is pulling from that list and the current value same thing you select from the list
select okay and let's see if we can use that over here equals parameter
and this time we'll click first name and because our first name is set the current value of michael
all these will filter to michael and if we were to change this here
to lisa now these are filtered to lisa now the last option is to create a parameter based on
a query and how would we do this it has to be based on a list you could either do a select
statement that could be one of your queries here it could be an uploaded file whatever you want
and in this example i'm just going to upload this comma separated list that i put together so let's
new query and add this test list and it will recognize what this is not too concerned about the
formatting for now let's just say okay and what we need to do in order for this to work and this is
important because if you have any sort of data set here that you want to use for this purpose what
you have to do is make sure that it's formatted as a list and to do that we will go to transform
with this selected and say convert to list and now this will put it in a single column
as a list and we can use this now let's hop back to customer and i'll show you how this works
if we go to occupation just like the other ones we'll do a filter equals and this
time we'll do a new parameter and call this occupation type text and this will be a query
now we have this option here test list because of what we just did current value i'll say management
okay now what we'll do is close and apply we have those three parameters it's refiltering
our data set and we're only getting back now results that met that criteria to make this a
little more clear i've added in the customer name here to this list so we can see a little clearly
a little more clearly what's actually happening and i'll filter it down to where it's not blank
when we change this now we can actually see what's going on
supply these changes now we're only getting michael and this
is all because the underlying data set is now only returning where that's true
change this to black
and there's only this
so we went through two different ways to add parameters one is just adding something right
on the page itself the second option we looked at was using a parameter within your queries
which would then limit the data that was returned and then showing how you would edit those which
would be using this edit parameters task here it's definitely not as intuitive to edit these
parameters as it is to just change filters so that's something to consider especially if your
users aren't as comfortable you know working up here and changing it and knowing where to look
whereas filters can be a little easier but this is how you would do it in power bi
thank you for watching if you found this helpful please feel free to like the video
leave a comment if you have any questions and i'll see you at the next video thank you