Forum Discussion
Dropdown list in slicer
Hi everyone,
I have a table called V_ABC, as shown in the photo below. I am wondering if Power BI can create dropdown lists called "From Week" and "To Week," allowing users to select values corresponding to each Project_ID and Phase_ID.
Additionally, I would like to set a condition where "To Week" must always be greater than "From Week."
If anyone has experience with this, please assist me. Thank you in advance!
Yes, absolutely possible in Power BI. Below I give a clear, working approach (step-by-step) plus the exact DAX you can drop into your model. The idea: make a small Week table (with a numeric week column), use two single-select slicers from that table as From Week and To Week, and then create measures that (1) apply the chosen range and (2) validate that To > From. Project_ID and Phase_ID slicers will naturally limit the weeks shown if you build the relationship as described.
1) Create a Week table (calculated table)
Use this calculated table in Modeling → New table:
WeekTable =
VAR w =
ADDCOLUMNS(
DISTINCT ( V_ABC[Phase_Week] ),
"WeekNum",
VALUE (
SUBSTITUTE( TRIM( [Phase_Week] ), "Week ", "" )
)
)
RETURN
SELECTCOLUMNS( w, "Phase_Week", [Phase_Week], "WeekNum", [WeekNum] )
Notes:
- This extracts WeekNum from strings like "Week 1". Adjust the SUBSTITUTE if your labels differ.
- WeekTable[Phase_Week] will be used for the slicer labels, and WeekNum is numeric for comparisons.
2) Create a relationship
Make a relationship in the model:
- WeekTable[WeekNum] (one) → V_ABC[WeekNum] (many).
If V_ABC does not yet have a numeric WeekNum, add a calculated column there:
V_ABC_WeekNum =
VALUE( SUBSTITUTE( TRIM( V_ABC[Phase_Week] ), "Week ", "" ) )
Then relate WeekTable[WeekNum] → V_ABC[V_ABC_WeekNum].
This relationship enables the Project_ID and Phase_ID slicers (on fields from V_ABC) to cross-filter the WeekTable, displaying only weeks relevant to the selected project/phase.
3) Add slicers to the report
- Add slicer for V_ABC[Project_ID] (multi or single select as you want).
- Add slicer for V_ABC[Phase_ID].
- Add two slicers for the week using WeekTable[Phase_Week]:
- Label one slicer "From Week"
- Label the other "To Week"
- Set both week slicers to Single select (so the user picks one value each).
Because of the relationship, when you select a Project and Phase, the week slicers will show only weeks available for that project/phase.
4) Selected week measures
Create these helper measures:
SelectedFromWeekNum :=
SELECTEDVALUE( WeekTable[WeekNum] )
SelectedToWeekNum :=
SELECTEDVALUE( WeekTable[WeekNum] )
(You can place them in a card during testing to see values; they return blank if nothing is selected.)
5) Validation measure (To must be > From)
Create a validation measure to show whether the selection is valid:
IsWeekRangeValid :=
VAR f = [SelectedFromWeekNum]
VAR t = [SelectedToWeekNum]
RETURN
IF(
OR( ISBLANK(f), ISBLANK(t) ),
BLANK(), // no message until both selected
IF( t > f, 1, 0 )
)
You can show this as a Card or use it in conditional formatting. 1 = valid, 0 = invalid.
Or an explanatory text measure for users:
WeekRangeMessage :=
VAR f = [SelectedFromWeekNum]
VAR t = [SelectedToWeekNum]
RETURN
IF(
OR( ISBLANK(f), ISBLANK(t) ),
"Please select From and To weeks.",
IF( t <= f, "Error: To Week must be greater than From Week.", "" )
)
Put WeekRangeMessage in a Card so users get immediate feedback.
6) Main measure that restricts data to the selected range
Example: count rows (or compute other metrics) in the selected week range and respecting Project_ID & Phase_ID slicers:
RowsInSelectedWeekRange :=
VAR f = [SelectedFromWeekNum]
VAR t = [SelectedToWeekNum]
RETURN
IF(
OR( ISBLANK(f), ISBLANK(t) ),
BLANK(), // or 0 if you prefer
IF(
t <= f,
BLANK(), // invalid selection -> blank (won't plot)
CALCULATE(
COUNTROWS( V_ABC ),
FILTER(
V_ABC,
V_ABC[V_ABC_WeekNum] >= f
&& V_ABC[V_ABC_WeekNum] <= t
)
)
)
)
Important: I did not remove filters in CALCULATE, so this result will still honor Project_ID and Phase_ID slicers. If you do want to ignore Project/Phase filters, wrap the V_ABC table with ALL(V_ABC) inside FILTER.
7) UX tips/enforcement
- Power BI slicers themselves cannot force “To > From” (you can’t block a bad selection directly inside the slicer). Instead:
- Use the WeekRangeMessage card to show an error message when the user picks an invalid range.
- Use your measures to return BLANK() (or 0) when selection is invalid so charts/tables show nothing (or an alternate visualization prompting correction).
- Make both week slicers single select — this simplifies the logic.
- Optionally add a bookmark or a button wired to a measure/bookmark to clear selections (if you want a “Reset weeks” control).
- If your Phase_Week values are not always formatted as "Week N", adapt the parsing logic accordingly.
Example flow for the user
- User filters Project_ID and Phase_ID (optional).
- The From & To Week slicers show only weeks that exist for that project/phase.
- User picks From and To (single values). If To ≤ From:
- WeekRangeMessage card warns: “To Week must be greater than From Week.”
- Main visuals return BLANK (or show 0) until corrected.
- If valid, your visuals (table/chart counts, etc.) display results for rows where WeekNum is between From and To and also match selected Project/Phase.
If you found this post helpful, please consider accepting it as the solution so that other members can find it more easily.
Regards,
Khashayar Yazdani | Microsoft MCT
5 Replies
- v-hashadapuCommunity Support
Hi Amyries , Thank you for reaching out to the Microsoft Fabric Community Forum.
Khashayar provided the most complete step-by-step solution that’s perfect if you want your From Week and To Week slicers to dynamically respond to selected Project_ID and Phase_ID, since it uses a proper Week table and relationships within the model. Shahid12523 ’s disconnected-table approach is also valid and can be a bit simpler if you just want independent week pickers without adding relationships.
Each method works well; the best choice depends on how integrated you want the week filters to be with the rest of your model. If you’re still running into issues implementing either of these, please share the details.
DAX overview - DAX | Microsoft Learn
Thank you Khashayar & Shahid12523 for your valuable responses.
- KhashayarResolver I
Yes, absolutely possible in Power BI. Below I give a clear, working approach (step-by-step) plus the exact DAX you can drop into your model. The idea: make a small Week table (with a numeric week column), use two single-select slicers from that table as From Week and To Week, and then create measures that (1) apply the chosen range and (2) validate that To > From. Project_ID and Phase_ID slicers will naturally limit the weeks shown if you build the relationship as described.
1) Create a Week table (calculated table)
Use this calculated table in Modeling → New table:
WeekTable =
VAR w =
ADDCOLUMNS(
DISTINCT ( V_ABC[Phase_Week] ),
"WeekNum",
VALUE (
SUBSTITUTE( TRIM( [Phase_Week] ), "Week ", "" )
)
)
RETURN
SELECTCOLUMNS( w, "Phase_Week", [Phase_Week], "WeekNum", [WeekNum] )
Notes:
- This extracts WeekNum from strings like "Week 1". Adjust the SUBSTITUTE if your labels differ.
- WeekTable[Phase_Week] will be used for the slicer labels, and WeekNum is numeric for comparisons.
2) Create a relationship
Make a relationship in the model:
- WeekTable[WeekNum] (one) → V_ABC[WeekNum] (many).
If V_ABC does not yet have a numeric WeekNum, add a calculated column there:
V_ABC_WeekNum =
VALUE( SUBSTITUTE( TRIM( V_ABC[Phase_Week] ), "Week ", "" ) )
Then relate WeekTable[WeekNum] → V_ABC[V_ABC_WeekNum].
This relationship enables the Project_ID and Phase_ID slicers (on fields from V_ABC) to cross-filter the WeekTable, displaying only weeks relevant to the selected project/phase.
3) Add slicers to the report
- Add slicer for V_ABC[Project_ID] (multi or single select as you want).
- Add slicer for V_ABC[Phase_ID].
- Add two slicers for the week using WeekTable[Phase_Week]:
- Label one slicer "From Week"
- Label the other "To Week"
- Set both week slicers to Single select (so the user picks one value each).
Because of the relationship, when you select a Project and Phase, the week slicers will show only weeks available for that project/phase.
4) Selected week measures
Create these helper measures:
SelectedFromWeekNum :=
SELECTEDVALUE( WeekTable[WeekNum] )
SelectedToWeekNum :=
SELECTEDVALUE( WeekTable[WeekNum] )
(You can place them in a card during testing to see values; they return blank if nothing is selected.)
5) Validation measure (To must be > From)
Create a validation measure to show whether the selection is valid:
IsWeekRangeValid :=
VAR f = [SelectedFromWeekNum]
VAR t = [SelectedToWeekNum]
RETURN
IF(
OR( ISBLANK(f), ISBLANK(t) ),
BLANK(), // no message until both selected
IF( t > f, 1, 0 )
)
You can show this as a Card or use it in conditional formatting. 1 = valid, 0 = invalid.
Or an explanatory text measure for users:
WeekRangeMessage :=
VAR f = [SelectedFromWeekNum]
VAR t = [SelectedToWeekNum]
RETURN
IF(
OR( ISBLANK(f), ISBLANK(t) ),
"Please select From and To weeks.",
IF( t <= f, "Error: To Week must be greater than From Week.", "" )
)
Put WeekRangeMessage in a Card so users get immediate feedback.
6) Main measure that restricts data to the selected range
Example: count rows (or compute other metrics) in the selected week range and respecting Project_ID & Phase_ID slicers:
RowsInSelectedWeekRange :=
VAR f = [SelectedFromWeekNum]
VAR t = [SelectedToWeekNum]
RETURN
IF(
OR( ISBLANK(f), ISBLANK(t) ),
BLANK(), // or 0 if you prefer
IF(
t <= f,
BLANK(), // invalid selection -> blank (won't plot)
CALCULATE(
COUNTROWS( V_ABC ),
FILTER(
V_ABC,
V_ABC[V_ABC_WeekNum] >= f
&& V_ABC[V_ABC_WeekNum] <= t
)
)
)
)
Important: I did not remove filters in CALCULATE, so this result will still honor Project_ID and Phase_ID slicers. If you do want to ignore Project/Phase filters, wrap the V_ABC table with ALL(V_ABC) inside FILTER.
7) UX tips/enforcement
- Power BI slicers themselves cannot force “To > From” (you can’t block a bad selection directly inside the slicer). Instead:
- Use the WeekRangeMessage card to show an error message when the user picks an invalid range.
- Use your measures to return BLANK() (or 0) when selection is invalid so charts/tables show nothing (or an alternate visualization prompting correction).
- Make both week slicers single select — this simplifies the logic.
- Optionally add a bookmark or a button wired to a measure/bookmark to clear selections (if you want a “Reset weeks” control).
- If your Phase_Week values are not always formatted as "Week N", adapt the parsing logic accordingly.
Example flow for the user
- User filters Project_ID and Phase_ID (optional).
- The From & To Week slicers show only weeks that exist for that project/phase.
- User picks From and To (single values). If To ≤ From:
- WeekRangeMessage card warns: “To Week must be greater than From Week.”
- Main visuals return BLANK (or show 0) until corrected.
- If valid, your visuals (table/chart counts, etc.) display results for rows where WeekNum is between From and To and also match selected Project/Phase.
If you found this post helpful, please consider accepting it as the solution so that other members can find it more easily.
Regards,
Khashayar Yazdani | Microsoft MCT
- Shahid12523Community Champion
Create a disconnected Week_Selector table with values like "Week 1", "Week 2", etc.
Use two slicers: one for From Week, one for To Week.
Capture selected weeks using DAX: Selected_From_Week and Selected_To_Week.
Filter your V_ABC table using a DAX measure that checks if Phase_Week falls between the selected range and ensures To Week > From Week. - Kedar_PandeSuper User
1. Create two separate tables for "From Week" and "To Week" using SUMMARIZE(V_ABC, V_ABC[Project_ID], V_ABC[Phase_ID], V_ABC[Week]). Use these new tables to build your dropdowns.
2. IF(
SELECTEDVALUE('To Week'[Week]) > SELECTEDVALUE('From Week'[Week]),
[Your Actual Measure],
BLANK()
)For the condition, use this measure for your calculation:
- v-hashadapuCommunity Support
Hi Amyries , Hope you're doing fine. Can you confirm if the problem is solved or still persists? Sharing your details will help others in the community.