The ultimate Fabric, Power BI, SQL, and AI community-led learning event. Save €200 with code FABCOMM.
Get registeredCompete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.
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
Solved! Go to Solution.
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.
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:
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.
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.
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:
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.
User | Count |
---|---|
17 | |
8 | |
7 | |
6 | |
6 |
User | Count |
---|---|
26 | |
13 | |
12 | |
9 | |
8 |