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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Syndicate_Admin
Administrator
Administrator

Current year by default as no year selected

Hello

I have a report that has a segmentation of data by year, where I visualize my amounts depending on the selected year. I need that when I DO NOT select any year the graphs or measures show me by default the amounts of the maximum (or current) year. There is a way to do it.

Thank you

1 ACCEPTED SOLUTION
aduguid
Super User
Super User

In Power BI using DAX, you can create a measure that checks if the slicer value is blank and, if so, applies the maximum year as the filter. Here’s how you can do it:

  1. Create a Year Slicer: Ensure you have a slicer in your Power BI report that allows users to select a year.

  2. Create a Measure: Write a DAX measure to apply the maximum year when the slicer is blank.

Here is an example of how you can do this:

 

SelectedYear =
IF(
    ISBLANK(SELECTEDVALUE('Calendar'[Year])),
    MAX('Calendar'[Year]),
    SELECTEDVALUE('Calendar'[Year])
)

 

  • 'Calendar'[Year] is the column from your date table (replace Calendar with your actual date table name).
  • SELECTEDVALUE('Calendar'[Year]) gets the value selected in the slicer.
  • ISBLANK(SELECTEDVALUE('Calendar'[Year])) checks if the slicer value is blank.
  • MAX('Calendar'[Year]) gets the maximum year from your date table.
  1. Use the Measure in Your Visuals: Apply this measure as a filter or use it directly in your visuals. For instance, if you have a visual that needs to be filtered by year, you can use the SelectedYear measure to ensure it always uses the maximum year when no year is selected in the slicer.

To apply this measure as a filter, you can use it in the Filter pane by setting it in the filter section of your visuals.

Here is an example of how you might use it in a visual calculation:

 

SalesAmountFiltered =
CALCULATE(
    SUM(Sales[SalesAmount]),
    'Calendar'[Year] = [SelectedYear]
)

 

 

View solution in original post

1 REPLY 1
aduguid
Super User
Super User

In Power BI using DAX, you can create a measure that checks if the slicer value is blank and, if so, applies the maximum year as the filter. Here’s how you can do it:

  1. Create a Year Slicer: Ensure you have a slicer in your Power BI report that allows users to select a year.

  2. Create a Measure: Write a DAX measure to apply the maximum year when the slicer is blank.

Here is an example of how you can do this:

 

SelectedYear =
IF(
    ISBLANK(SELECTEDVALUE('Calendar'[Year])),
    MAX('Calendar'[Year]),
    SELECTEDVALUE('Calendar'[Year])
)

 

  • 'Calendar'[Year] is the column from your date table (replace Calendar with your actual date table name).
  • SELECTEDVALUE('Calendar'[Year]) gets the value selected in the slicer.
  • ISBLANK(SELECTEDVALUE('Calendar'[Year])) checks if the slicer value is blank.
  • MAX('Calendar'[Year]) gets the maximum year from your date table.
  1. Use the Measure in Your Visuals: Apply this measure as a filter or use it directly in your visuals. For instance, if you have a visual that needs to be filtered by year, you can use the SelectedYear measure to ensure it always uses the maximum year when no year is selected in the slicer.

To apply this measure as a filter, you can use it in the Filter pane by setting it in the filter section of your visuals.

Here is an example of how you might use it in a visual calculation:

 

SalesAmountFiltered =
CALCULATE(
    SUM(Sales[SalesAmount]),
    'Calendar'[Year] = [SelectedYear]
)

 

 

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.