You can use the previous_value function to accomplish this
TRIM( ATTR( [Offer Type] + ' ') + PREVIOUS_VALUE('') ) restart computing on every ID
Next add a filter last() = 0 to keep the last row
Book2(mc).twbx 15.9 KB
Thanks for that Micheal. Can you help me understand though, what is the point of the LAST() calc? I get everything except that, even when viewing it in context. Why should it matter whether we're looking at the last or the first row given the table calc specifies that it should restart for every ID?
If you look at the ValidateData sheet, you see that the concat calculation returns it's value of the previous row, concatenated with the Offer Type of the current row. So the final string that you are looking for is displayed on the last ID row. And the last() = 0 returns true on that row.
Now the FinalView sheet is a duplicate of the ValidateData sheet, where the Offer Type dimension is hidden (right-click blue pill, unselect Show Header) . Remember that we need to keep Offer Type in the view in order to be able to compute the previous_value.
And the goal of the last() = 0 calculation, is to use it as a filter and keep the true values, in order to hide from the view the rows that are needed for the calculation, but we don't want the user to see.
It may seems confusing, since you filter out the first rows, how come the concat calculation still works. In Tableau all table calculations are computed before table calculation filters are applied. And both previous_value() and last() are table calculations. So when the last() = 0 filter is applied, the concat calculation have already been computed.