Skip to main content
Abby Ebelherr a posé une question dans #Tableau Public

In this workbook, under the Change # sheet, I would like the tooltip to display 2017 and 2022 estimates (separately) when the 2017-2022 range is selected and 2019 and 2024 estimates when the 2019-2024 range is selected. If you hover over the tooltip, you can see how I would like the data to be arranged. Is this possible? 

 

#Tableau Public

6 réponses
  1. 26 févr., 13:33

    @Abby Ebelherr

    not sure what happened to my follow-up post yesterday evening, but its not showing this morning.  The following is going to look more confusing to you but I'm a user of regular expressions functions (REGEX) these days when dealing with string (text) based needs. 

     

    Calculation3

    IF MIN([Year Range])='2017-2022' THEN 'The 2017 estimate is: ' +

    REGEXP_REPLACE(STR(SUM([2017 Estimate])), '^(-?\d+)(\d{3})$', '$1,$2')

    + ' and the 2022 estimate is: ' +

    REGEXP_REPLACE(STR(SUM([2022 Estimate])), '^(-?\d+)(\d{3})$', '$1,$2')

    + ' a difference of ' +

    REGEXP_REPLACE(STR(SUM([Difference])), '^(-?\d+)(\d{3})$', '$1,$2')

    //When Year Range filter is changed

    ELSEIF MIN([Year Range])='2019-2024' THEN 'The 2019 estimate is: ' +

    REGEXP_REPLACE(STR(SUM([2019 Estimate])), '^(-?\d+)(\d{3})$', '$1,$2')

    + ' and the 2024 estimate is: ' +

    REGEXP_REPLACE(STR(SUM([2024 Estimate])), '^(-?\d+)(\d{3})$', '$1,$2')

    + ' a difference of ' +

    REGEXP_REPLACE(STR(SUM([Difference])), '^(-?\d+)(\d{3})$', '$1,$2')

    END

     

    Which then returns: 

     

    not sure what happened to my follow-up post yesterday evening, but its not showing this morning.

     

     

    Essentially leveraging the former calculations each of 2019 and 2024 Estimates (and the other two estimate calc's).  The REGEX function is looking for 3-digits from the end of the string (text) and if there are only 3-digits then it does nothing.  But if the the REGEX detects more than 3-digits, then the parser is supplying a comma (thousands separator) between any digits greater than 3 and the original 3 digits. 

     

0/9000