Join us for an expert-led overview of the tools and concepts you'll need to pass exam PL-300. The first session starts on June 11th. See you there!
Get registeredPower BI is turning 10! Let’s celebrate together with dataviz contests, interactive sessions, and giveaways. Register now.
Hello All,
I have passed year,month,day in heirarchy slicer from Date table. Date table has a date range from 01-01-2015 to 12-31-2060.
Passing below measure on slicer (filters Pane) I have restricted it to 2020 and 2021.
Solved! Go to Solution.
Found the solution
created a calculated column
created a calculated column
// I can't open your files as I'm
// behind my company's firewall and
// can't download or open files from
// Google Drive.
// Say that you have a date table and
// you have a slicer that displays
// Months. To get the last selected
// Month you'd write this measure:
[Last Selected MonthID] = MAX( Dates[MonthID] )
// To get the first selected month
// you'd write:
[First Selected MonthID] = MIN( Dates[MonthID] )
// Dates[MonthID] is a unique number
// that is assigned to months and it's
// unique across all years. So, the first
// month you have in your table should be
// 1 and move up by 1 every time you
// encounter a new month. So, the last
// MonthID should be equal to the number of
// all months you've got in your calendar.
// The problem with "I want to derive a measure
// which should display the non selected value
// from slicer if i deselect any month from slicer."
// is that a measure can return only a scalar
// value, not a table. So, if you deselect more
// than 1 month, such a measure out of necessity
// will return BLANK. Say that out of all months
// you've deselected only 1 month from the slicer
// and want to return the ID of this month.
// Then you write:
[Deselected MonthID] =
var DeselectedMonthIDs =
EXCEPT(
ALL( Dates[MonthID] ),
DISTINCT( Dates[MonthID] )
)
var Result =
if( COUNTROWS( DeselectedMonthID ) = 1,
DeselectedMonthID
)
return
Result
// The assumption is that you store only relevant
// periods of time in your table, not something
// like 60 years ahead. To manage the number of years
// and the start and end of the date table, you can
// and, indeed, should use Power Query parameters.
Found the solution
created a calculated column
this we need to keep hierarchy slicer as it is there in pbix file
Example- if we deselect June 2021 then range of 15 months should start from May 2021 and should 15 months back upto March 2020.
Still any confusion please connect with me.
Fact table has prev year sales & current year sales columns alongwith date column which is connected with date table which has data from 2018 to 2023. need to show comparision of current year sales vs prev year sales on bar chart
created a calculated column
I think you need to watch this: Show last 6 months based on user single slicer selection - SQLBI
Take a good look at the technique Alberto presents.
In the above video reference date (max date) is a key parameter which can only be derived if we get to know the first date of deselected month that is why i want a measure which should return a date of least unselected month.
Please have a look at sample file
https://drive.google.com/file/d/1_XXUBsXdQVPf3SzR4NykKmTKR4dwhdfQ/view?usp=sharing
@Anonymous
First and foremost, you should have a proper calendar in your model and never, ever rely on the automatically generated datetime hierarchy. I mean: NEVER.
This notation 'Table'[Date].[XXX] should never happen in your model, either. It's simply wrong on too many levels. All the periods you need in your report must be created in columns of a dedicated Date/Calendar table.
By the way, to load a specific Date range into your calendar you can use Power Query parameters. No idea why you'd like to store dates until 2060. It only unnecessarily takes space.
You should not complicate things that can be done easily.
"now I want to derive a measure which should display the non selected value from slicer if i deselect any month from slicer"
Where do you want to display it? In what format? What should happen if you deselect more than 1 month or all months? What if you deselect just several days in a month? Can you be more specific with your questions, please?
If we deselect more than 1 month then datarange should start from previous month of minimum deslected month (if march and april both are deslected the datarange should be Feb -15 months) there will not be any option to deselect any days
In slicer I have 2 years (2020 & 2021) if whole 2020 & 2021 is selected then it should should show total 15 bars (Current Month -12 months and also next 2 months) like below
If any of the month is deselected (both 2020 & 2021 is selected) then it show 15 bars (previous month from deselected month also last 15 months) like below (in this June 2021 is deselected then last 15 months data)
If whole 2021 is selected then (June is current Month)
If whole 2021 is selected and june (Current Month) unselected then
@amitchandak @PBICommunity @Anonymous @Fowmy Please help
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
14 | |
10 | |
10 | |
9 | |
9 |
User | Count |
---|---|
20 | |
13 | |
13 | |
11 | |
8 |