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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

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
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors