Forum Discussion
heatherkw
3 years agoHelper I
Dynamic Text Using List Separated by Commas and or Before Last Value
Hello, A long timeago I found something that provided the solution I'm looking for, but I can't seem to find it again. I have a slicer for program type and users can select 1-5 values. I am usin...
- 3 years ago
Thanks! This helped lead me down the right path. I still had to do some tweaking, but this works for me based on how it's set up in my dashboard.
ProjectSelection_Exits = VAR SelectedProj = VALUES(ExitsPH_HUD[RecodePgmType]) VAR NumberOfSelectedProj = COUNTROWS (SelectedProj) VAR AllButLastProj = TOPN(NumberOfSelectedProj - 1, SelectedProj) VAR LastSelectedProj = EXCEPT(SelectedProj, AllButLastProj) RETURN IF(NumberOfSelectedProj = 3 || NumberOfSelectedProj = 4, CONCATENATEX(AllButLastProj, ExitsPH_HUD[RecodePgmType], ", ") & ", or " & LastSelectedProj, IF(NumberOfSelectedProj = 2, CONCATENATEX(AllButLastProj, ExitsPH_HUD[RecodePgmType], ", ") & " or " & LastSelectedProj, IF(NumberOfSelectedProj = 1, LastSelectedProj, "all service types")))
Sergii24
3 years agoSuper User
Well, we can modify the same measure:
Dynamic Title Measure =
VAR _NumOfProjectsSelected = COUNTROWS( Projects )
VAR _AllSelectedProjectsExceptLastOne = //this 1 column table will have all projects except 1 selected, so we'll use CONCATENATEX later for this one
SELECTCOLUMNS( //SELECTCOLUMNS is added in case you have multiple columns in Projects table, which are not necessary in this measure
TOPN(
_NumOfProjectsSelected - 1,
Projects,
Projects[Project Title],
ASC //important that here you use a value different from the one in _LastSelectedProject
),
"@Project Title", [Project Title]
)
VAR _LastSelectedProject = //this 1 column table will always have only 1 row
SELECTCOLUMNS(
TOPN(
1,
Projects,
Projects[Project Title],
DESC //important that here you use a value different from the one in _AllSelectedProjectsExceptLastOne
),
"@Project Title", [Project Title]
)
RETURN
IF(
_NumOfProjectsSelected > 3,
"More than 3 projects selected",
IF(
_NumOfProjectsSelected > 1,
CONCATENATEX( _AllSelectedProjectsExceptLastOne, [@Project Title], ", " ) & " and " & _LastSelectedProject,
_LastSelectedProject
)
)
I hope it is what you've been looking for! 🙂
heatherkw
3 years agoHelper I
Thanks! This helped lead me down the right path. I still had to do some tweaking, but this works for me based on how it's set up in my dashboard.
ProjectSelection_Exits =
VAR SelectedProj = VALUES(ExitsPH_HUD[RecodePgmType])
VAR NumberOfSelectedProj = COUNTROWS (SelectedProj)
VAR AllButLastProj = TOPN(NumberOfSelectedProj - 1, SelectedProj)
VAR LastSelectedProj = EXCEPT(SelectedProj, AllButLastProj)
RETURN
IF(NumberOfSelectedProj = 3 || NumberOfSelectedProj = 4, CONCATENATEX(AllButLastProj, ExitsPH_HUD[RecodePgmType], ", ") & ", or " & LastSelectedProj,
IF(NumberOfSelectedProj = 2, CONCATENATEX(AllButLastProj, ExitsPH_HUD[RecodePgmType], ", ") & " or " & LastSelectedProj,
IF(NumberOfSelectedProj = 1, LastSelectedProj, "all service types")))