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

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

Reply
Anonymous
Not applicable

Filter function not working on DATE table

Hi Everyone,

I have date table, within which there are columns "Year" and "Current Year".
The DAX for Current Year is = 

if(YEAR(Date_Dimension[Date])=Year(TODAY()),"Current Year",Date_Dimension[Year]).
Both Year and Current Year are in Text Format.(I cannot change it).
I will be using Current year in a slicer.
I have created a measure, in which I need to calculate for previous year which is not working for me. Can anyone of guys help a brother out?
 
Selectedyear =
VAR SelectedYear =
    IF(
        ISFILTERED(Date_Dimension[Current Year]) &&
        SELECTEDVALUE(Date_Dimension[Current Year]) = "Current Year",
        VALUE(MAX(Date_Dimension[Year])) - 1,
        VALUE(SELECTEDVALUE(Date_Dimension[Year])) - 1
    )
VAR Formatter = FORMAT(SelectedYear, "####")

RETURN
Formatter

The measure that I created, 
 
Measure 2 =
CALCULATE(
    SUM('Sales'[Quantity]),
    FILTER( Date_Dimension,
    Date_Dimension[Year] = [Selectedyear]
)
)
Now of I select anything in Slicer, it is just showing blank.
2 REPLIES 2
amitchandak
Super User
Super User

@Anonymous , Try like

 

Measure 2 =
CALCULATE(
SUM('Sales'[Quantity]),
FILTER(all( Date_Dimension),
Date_Dimension[Year] = [Selectedyear]
)
)

 

 

If you want to default the year on Current year, You need a column

 

Year Type = Switch( True(),
year([Date])= year(Today()),"This Year" ,
year([Date])= year(Today())-1,"Last Year" ,
Format([Date],"YYYY")
)

 

 

Default Date Today/ This Month / This Year: https://www.youtube.com/watch?v=hfn05preQYA

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi Ankit,
Thank you for the reply. I used the ALL function in the measure as well. It is resulting in blank.

 

Is there any other work around?

Helpful resources

Announcements
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