Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
MJ77
New Member

I want to add a slicer for date Hierachy which enables users to choose hierachy e.g. Years or months

In power BI I have a universal date table i am using for all queries. Its in DateTable[Date]. The date is a daily date but spans many years so if its kept at Day, it can be overly detailed. Therefore, For my line chart, i want to add a slicer where users can choose at what hierachy level they view the chart, i.e. if they want to view it in months, or in years or months, or days etc.

2 REPLIES 2
bhanu_gautam
Super User
Super User

@MJ77 , You need a measure that dynamically adjusts based on the selected hierarchy level. 

 

SelectedDateLevel =
SWITCH(
TRUE(),
ISFILTERED(DateTable[Year]) && NOT ISFILTERED(DateTable[Month]), "Year",
ISFILTERED(DateTable[Month]) && NOT ISFILTERED(DateTable[Day]), "Month",
ISFILTERED(DateTable[Day]), "Day",
"None"
)

 

Then create a measure  that adjusts the aggregation based on the selected date level

DynamicMeasure =
SWITCH(
[SelectedDateLevel],
"Year", CALCULATE(SUM(Sales[Amount]), ALLEXCEPT(DateTable, DateTable[Year])),
"Month", CALCULATE(SUM(Sales[Amount]), ALLEXCEPT(DateTable, DateTable[Year], DateTable[Month])),
"Day", CALCULATE(SUM(Sales[Amount]), ALLEXCEPT(DateTable, DateTable[Year], DateTable[Month], DateTable[Day])),
SUM(Sales[Amount])
)

 

Use this dynamic measure in Y-axis




Did I answer your question? Mark my post as a solution! And Kudos are appreciated

Proud to be a Super User!




LinkedIn






Thank you however. i want a slicer to be available to users of the report to also select the hierachy level a which they want to view th report

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.

Top Solution Authors