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

Get inspired! Check out the entries from the Power BI DataViz World Championships preliminary rounds and give kudos to your favorites. View the vizzies.

Reply
dogt1225
Helper III
Helper III

Custom Period Slicer to default to specific date fields

I have a custom period filter for "Last 5 Quarters", "Last 5 Months", and "Last 5 Weeks". And a Parameter that dynamically filters the x axis based on 3 date fields, [Fiscal Year Quarter], [Fiscal Year Month], [Fiscal Year Week]


I am looking to have the functionality where,
 - If a user selects "Last 5 Quarters", then the Parameter is default to "Fiscal Year Quarter"
- If a user selects "Last 5 Months" , then Parameter is default to "Fiscal Year Month"... etc. 

Therefore I can remove the "Parameter" slicer from the report. Is there a way for this?

dogt1225_0-1680637232257.png

 

dogt1225_1-1680637265999.png

 

 

 

 

Parameter = {
    ("Fiscal Year Quarter", NAMEOF('Date'[Fiscal Year Quarter]), 0),
    ("Fiscal Year Month", NAMEOF('Date'[Fiscal Year Month]), 1),
    ("Fiscal Year Week", NAMEOF('Date'[Fiscal Year Week]), 2)
}
Period Filter = 

VAR _selectedperiod = SELECTEDVALUE('Last 5 Custom Period'[Period-Order])
    
VAR _last5qtr = 
    IF(
        CALCULATE(
            MAX('Date'[Date]),
            'Date'[Fiscal Year Quarter (Offset)] >= -4 && 'Date'[Fiscal Year Quarter (Offset)] <= 0
        ), 
        1, 
        0
    )

VAR _last5months = 
    IF(
        CALCULATE(
            MAX('Date'[Date]),
            'Date'[Fiscal Year Month (Offset)] >= -4 && 'Date'[Fiscal Year Month (Offset)] <= 0
        ), 
        1, 
        0
    )

VAR _last5wks = 
    IF(
        CALCULATE(
            MAX('Date'[Date]),
            'Date'[Fiscal Year Week (Offset)] >= -4 && 'Date'[Fiscal Year Week (Offset)] <= 0
        ), 
        1, 
        0
    )

RETURN
   INT(SWITCH(            
    _selectedperiod, 1, _last5qtr,
                     2, _last5months, 
                     3, _last5wks
   ))

 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@dogt1225 , you can change the measure based on selected axis value. 

Just remember for trends using a date/period, date/period should come from an independent table

 

Changing measures based on the axis with Field Parameters in Power BI. Dynamic measures based on the axis/Dimension: https://youtu.be/7ikRAelDph0

Switch TOPN with Field Parameters: https://amitchandak.medium.com/switch-topn-with-field-parameters-299a0ae3725f

 

Power BI Abstract Thesis: Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

1 REPLY 1
amitchandak
Super User
Super User

@dogt1225 , you can change the measure based on selected axis value. 

Just remember for trends using a date/period, date/period should come from an independent table

 

Changing measures based on the axis with Field Parameters in Power BI. Dynamic measures based on the axis/Dimension: https://youtu.be/7ikRAelDph0

Switch TOPN with Field Parameters: https://amitchandak.medium.com/switch-topn-with-field-parameters-299a0ae3725f

 

Power BI Abstract Thesis: Need of an Independent Date Table:https://www.youtube.com/watch?v=44fGGmg9fHI

Full Power BI Video 20 Hours YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code FABINSIDER for a $400 discount!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

March2025 Carousel

Fabric Community Update - March 2025

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