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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
Anonymous
Not applicable

power bi dax measure add context to measure

Hello,

Hope you are doing well,

My PBI report has two slicers for date: "start date" and "end date".

The start date slicer is being ignored in my visuals.

This is posing an issue: I want to do a measure based on that slicer - "start date" - and I add it to those visuals; however, because the slicer is being ignored I can not catch the start date in this measure. I am catching the first date of Calendar'[Date] instead of the date selected in the slicer. 

What can be done?

 

DETAILS:

Measure Start Date: 1StartDate =

VAR StartDate = MIN('Calendar'[Date])
Return StartDate


Table Calendar: Calendar =
var minyear = YEAR ( min( all_countries_DWH[sk_date_date_format] ) )
var maxyear = IF(YEAR( MAX( all_countries_DWH[sk_date_date_format] ) ) > YEAR(TODAY()), YEAR(TODAY()), YEAR( MAX( all_countries_DWH[sk_date_date_format] ) ))
var minmonth = MONTH( MIN( all_countries_DWH[sk_date_date_format] ) )
var maxmonth = IF(MONTH( MAX( all_countries_DWH[sk_date_date_format] ) ) > MONTH(TODAY()), MONTH(TODAY()), MONTH( MAX( all_countries_DWH[sk_date_date_format] ) ))

RETURN
ADDCOLUMNS(
FILTER(
CALENDARAUTO(),
[Date] >= min( all_countries_DWH[sk_date_date_format] ) &&
[Date] <= max( all_countries_DWH[sk_date_date_format] )
--YEAR([Date]) >= minyear &&
--YEAR([Date]) <= maxyear //&&
--MONTH([Date]) >= minmonth &&
--month([Date]) <= maxmonth
),
"Year",YEAR([Date]),
"Month", FORMAT([Date],"mmm"),
"Month Number", MONTH([Date]),
"Quarter",FORMAT([Date],"\QQ"),
"Year/Month",FORMAT([Date],"yyyymm"),
"Week Number", WEEKNUM([Date]),
"Week",
VAR week_start = [Date] - WEEKDAY([Date], 1) + 1 // Calculate the start of the week (Sunday)
VAR week_end = week_start + 6 // Calculate the end of the week
RETURN
WEEKNUM([Date]) & ", " &
FORMAT(week_start, "d MMM") & " - " & FORMAT(week_end, "d MMM") & " " & YEAR([Date])
)

 

Regards

Manuel

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi @Anonymous

 

Based on the information you've provided, it looks like your measure ”StartDate“ is using ”MIN('Calendar'[Date])“ which will return the minimum date from the entire 'Calendar' table, not taking into account the slicer selection.

 

Here are the modifications I've made to your dax:

 

Modify the "StartDate" measure to use the "SELECTEDVALUE" function, which returns the value currently selected in the slicer, or a default value if nothing is selected.

 

vnuocmsft_2-1704877005809.png

 

StartDate = 
    SELECTEDVALUE(
        'Calendar'[Date], 
        MIN('Calendar'[Date])
    )

 

 

This measure will return the selected start date if there is one, or the minimum date from the 'Calendar' table if no date is selected. Like this:

vnuocmsft_3-1704877084057.png

If you're still having problems, provide some dummy data and the desired outcome. It is best presented in the form of a table.

 

Regards,

Nono Chen

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

1 REPLY 1
Anonymous
Not applicable

Hi @Anonymous

 

Based on the information you've provided, it looks like your measure ”StartDate“ is using ”MIN('Calendar'[Date])“ which will return the minimum date from the entire 'Calendar' table, not taking into account the slicer selection.

 

Here are the modifications I've made to your dax:

 

Modify the "StartDate" measure to use the "SELECTEDVALUE" function, which returns the value currently selected in the slicer, or a default value if nothing is selected.

 

vnuocmsft_2-1704877005809.png

 

StartDate = 
    SELECTEDVALUE(
        'Calendar'[Date], 
        MIN('Calendar'[Date])
    )

 

 

This measure will return the selected start date if there is one, or the minimum date from the 'Calendar' table if no date is selected. Like this:

vnuocmsft_3-1704877084057.png

If you're still having problems, provide some dummy data and the desired outcome. It is best presented in the form of a table.

 

Regards,

Nono Chen

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

 

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.