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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
Mahamood0218
Helper II
Helper II

How to get selected month from date table

Hi Experts ,

i want create a dax function for selected month date 

Mahamood0218_0-1652784190508.png

above pic is sample data

Requiremnt 

if i select filter as  year 2022 dax fucntion (Dateselected month) should be like as 01-05-2022

output like below

 

Mahamood0218_1-1652784426983.png

 

 

2 ACCEPTED SOLUTIONS
BA_Pete
Super User
Super User

Hi @Mahamood0218 ,

 

If your date is always the first of May on the year that you select, then the DAX for your card display would be something like this:

_selectionStartDate =
VAR __year = SELECTEDVALUE(calendar[year])
RETURN
FORMAT(
    DATE(__year, 05, 01),
    "dd-MM-yyyy"
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

Hi @Mahamood0218 ,

 

No, the month in this example is fixed, it's only the year that is dynamic based on the selected slicer value.

If you want it to always default to the first of the current month, then you would use something like this:

_DateSelectedMonthStart = 
VAR __year = SELECTEDVALUE(DimDate[Year])
VAR __month = MONTH(TODAY())
RETURN
FORMAT(
    DATE(__year, __month, 01),
    "dd-MM-yyyy"
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




View solution in original post

3 REPLIES 3
BA_Pete
Super User
Super User

Hi @Mahamood0218 ,

 

If your date is always the first of May on the year that you select, then the DAX for your card display would be something like this:

_selectionStartDate =
VAR __year = SELECTEDVALUE(calendar[year])
RETURN
FORMAT(
    DATE(__year, 05, 01),
    "dd-MM-yyyy"
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Hi @BA_Pete ,

Thanks for shared the code i have applied above code now it is working,

Mahamood0218_1-1652857544951.png

Note: I have another question in your code you had directly mentioned in DATE(Year,05,01) means month as mentioned directly ''05'' if i  will login the same pbi report next month my dax function "DateSelectedMonthstart2" will shows like  ''01-06-2022''?

 

Hi @Mahamood0218 ,

 

No, the month in this example is fixed, it's only the year that is dynamic based on the selected slicer value.

If you want it to always default to the first of the current month, then you would use something like this:

_DateSelectedMonthStart = 
VAR __year = SELECTEDVALUE(DimDate[Year])
VAR __month = MONTH(TODAY())
RETURN
FORMAT(
    DATE(__year, __month, 01),
    "dd-MM-yyyy"
)

 

Pete



Now accepting Kudos! If my post helped you, why not give it a thumbs-up?

Proud to be a Datanaut!




Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 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 Solution Authors