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

To celebrate FabCon Vienna, we are offering 50% off select exams. Ends October 3rd. Request your discount now.

Reply
Anonymous
Not applicable

How to calculate in measure for date picker selected year

Hello everyone,

 

I'm not sure if I'm my dax variable is correct but I need a year picker (slicer). I need date picker when a user pick a year it will calculate the picked year + 1 and the first day of the following year. Example it means when a user pick year 2021 , dax will return to the date 01/01/2022.

 

I created this one :

VAR SelectedYear = SELECTEDVALUE('Calendar'[Date].[Year])
VAR FirstDayOfNextYear = DATE(SelectedYear+1, 1, 1)
 
I'm not sure if it's correct because I don't get correct data . 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous 

Based on your needs, I have created the following table.

vjialongymsft_0-1731651855575.png

 

Using the formula you provided, the result will always return 1/1/1901.

vjialongymsft_1-1731651930276.png

 

You only need to make slight modifications to your Dax to achieve your needs:

M2 = 
var SelectedYear = YEAR(SELECTEDVALUE('Table'[Date]))
RETURN
 DATE(SelectedYear+1, 1, 1)

 

Result:

vjialongymsft_2-1731652021683.png

vjialongymsft_3-1731652033798.png

 

 

 

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

8 REPLIES 8
Anonymous
Not applicable

Hi @Anonymous 

Based on your needs, I have created the following table.

vjialongymsft_0-1731651855575.png

 

Using the formula you provided, the result will always return 1/1/1901.

vjialongymsft_1-1731651930276.png

 

You only need to make slight modifications to your Dax to achieve your needs:

M2 = 
var SelectedYear = YEAR(SELECTEDVALUE('Table'[Date]))
RETURN
 DATE(SelectedYear+1, 1, 1)

 

Result:

vjialongymsft_2-1731652021683.png

vjialongymsft_3-1731652033798.png

 

 

 

 

 

 

Best Regards,

Jayleny

 

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Anonymous
Not applicable

Hi @Anonymous 

Has your problem been resolved? If so, could you share your solution so that others with similar issues can benefit from it?

 


Best Regards,

Jayleny

vojtechsima
Super User
Super User

Hello, @Anonymous 

this measure is essentially fine, depends what you wanna do with it.

I recommend using physical columns for Year (just for clarity) instead of Date.Year.

If you mark your calendar as Date Table, you should lose this option anyway.

 

then it depends on your exact measure what you wanna achieve.

 

you can have something like this:

Measure = 
var _year = SELECTEDVALUE('Calendar'[Year])+1
CALCULATE(
SUM('Table'[idk]),
'Calendar'[Year] = _year
)
Anonymous
Not applicable

my meausure should pick up values in first top row... with criteria mentioned below..
PendingCasesCount411 =
VAR SelectedYear = SELECTEDVALUE('Calendar'[Date].[Year])
VAR FirstDayOfNextYear = DATE(SelectedYear+1, 1, 1)
RETURN
    COUNTROWS(
        FILTER(
            CecCaseDetail,
            VAR TopEvent =
                TOPN(
                    1,
                    FILTER(
                        CecCaseEvent,
                        CecCaseEvent[CecCaseID] = CecCaseDetail[CaseID] &&
                        CecCaseEvent[ToStateOfProceedingID] <> CecCaseEvent[FromStateOfProceedingID] &&
                        CecCaseEvent[EventDate] < FirstDayOfNextYear
                    ),
                    CecCaseEvent[EventOrder],
                    DESC
                )
            VAR SopBeforeDate =
                IF(
                    NOT ISEMPTY(TopEvent),
                    SELECTCOLUMNS(TopEvent, "ToStateOfProceedingID", CecCaseEvent[ToStateOfProceedingID])
                )
            RETURN
                SopBeforeDate IN {2, 3, 4}
        )
    )

Hi @Anonymous 

 

Use the below dax:

PendingCasesCount411 =
VAR SelectedYear = SELECTEDVALUE('Calendar'[Date].[Year])
VAR FirstDayOfNextYear = DATE(SelectedYear + 1, 1, 1)

RETURN
    COUNTROWS(
        FILTER(
            CecCaseDetail,
            VAR TopEvent =
                TOPN(
                    1,
                    FILTER(
                        CecCaseEvent,
                        CecCaseEvent[CecCaseID] = CecCaseDetail[CaseID] &&
                        CecCaseEvent[ToStateOfProceedingID] <> CecCaseEvent[FromStateOfProceedingID] &&
                        CecCaseEvent[EventDate] < FirstDayOfNextYear
                    ),
                    CecCaseEvent[EventOrder],
                    DESC
                )
            VAR SopBeforeDate =
                IF(
                    NOT ISEMPTY(TopEvent),
                    SELECTCOLUMNS(TopEvent, "ToStateOfProceedingID", CecCaseEvent[ToStateOfProceedingID])
                )
            RETURN
                SopBeforeDate IN {2, 3, 4}
        )
    )

@Anonymous try adding ALL(CecCaseEvent) to the measure.

   FILTER(
                        ALL(CecCaseEvent),
                        CecCaseEvent[CecCaseID] = CecCaseDetail[CaseID] &&
                        CecCaseEvent[ToStateOfProceedingID] <> CecCaseEvent[FromStateOfProceedingID] &&
                        CecCaseEvent[EventDate] < FirstDayOfNextYear
                    )

 

btw you can send me sample file (post link from onedrive/google) and I can work on it directly.

Anonymous
Not applicable

sure I sent you email

Anonymous
Not applicable

I need data that will get all before 01/01/2022, sorry I mentioned it.

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.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Kudoed Authors