最新消息:Welcome to the puzzle paradise for programmers! Here, a well-designed puzzle awaits you. From code logic puzzles to algorithmic challenges, each level is closely centered on the programmer's expertise and skills. Whether you're a novice programmer or an experienced tech guru, you'll find your own challenges on this site. In the process of solving puzzles, you can not only exercise your thinking skills, but also deepen your understanding and application of programming knowledge. Come to start this puzzle journey full of wisdom and challenges, with many programmers to compete with each other and show your programming wisdom! Translated with DeepL.com (free version)

tableau desktop - Any way to get my % of total str to format in this INT() calc? - Stack Overflow

matteradmin8PV0评论

I have a calc where I want to produce a continuous measure based on a case statement. I want the strings to format sufficient based on if I want '%' or not. The hours and FTE selections work correctly to populate separators, but the % of total selection results in nulls. I imagine because I'm wrapping an INT() around this calc so that I can create a continuous measure to model via a heatmap. Is there another way to do this?

INT(CASE [CIO Capacity Metrics Parameter]
    WHEN '%' THEN
        CASE [Incl. / Excl. OOO Parameter]
            WHEN 0 THEN STR(ROUND(100*(SUM([HRS_HOURS])/TOTAL(SUM([HRS_HOURS]))),0)) + '%'
            ELSE STR(ROUND(100*(SUM([Hours Total (Excl. OOO)])/TOTAL(SUM([Hours Total (Excl. OOO)]))),0)) + '%'  
        END
    WHEN 'FTE' THEN 
        CASE [Incl. / Excl. OOO Parameter]
            WHEN 0 THEN REGEXP_REPLACE(STR(ROUND(SUM([HRS_MONTH_FTE]),0)),"(\\d)(?=(\\d{3})+$)", "\\1," )
            ELSE REGEXP_REPLACE(STR(ROUND(SUM([FTE Total (Excl. OOO)]),0)),"(\\d)(?=(\\d{3})+$)", "\\1," )
        END
    WHEN 'Hours' THEN
        CASE [Incl. / Excl. OOO Parameter]
            WHEN 0 THEN REGEXP_REPLACE(STR(ROUND(SUM([HRS_HOURS]),0)),"(\\d)(?=(\\d{3})+$)", "\\1," )
            ELSE REGEXP_REPLACE(STR(ROUND(SUM([Hours Total (Excl. OOO)]),0)),"(\\d)(?=(\\d{3})+$)", "\\1," )
        END
END)

Post a comment

comment list (0)

  1. No comments so far