Forum Discussion

heatherkw's avatar
heatherkw
Helper I
3 years ago
Solved

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...
  • heatherkw's avatar
    heatherkw
    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")))