Forum Discussion
Stacked Bar Waterfall - problems with Measures and Calculated Columns
I would like to create a Stacked Bar Waterfall.
I can spoof a simple version in this way:
Month Name Hard Coded Count
| 1 Jan | Bob | 1 |
| 1 Jan | Fred | 1 |
| 1 Jan | Mary | 1 |
| 4 Feb | Bob | 1 |
| 4 Feb | Fred | 1 |
| 4 Feb | Anne | 1 |
| 3 Leavers | Mary | 1 |
| 2 Joiners | Ann | 1 |
| 3 Leavers | 1. Invisible | 3 |
| 2 Joiners | 1. Invisible | 3 |
Which allows me to create this 'spoof' because I have turned the 'invisible' value white.
However, this is hard coding the value for the 'invisible' value.
If I wanted the count to be dynamic, then I can calculate the invisible value in M Query by using Group:
#"Grouped Rows" = Table.Group(#"Changed Type", {"Month"}, {{"NewCount", each Table.RowCount(_), type number}})
I then bring that value for Jan and Feb into another step that generates the value for invisible...so far, so good.
HOWEVER....this only works for the relatively simply dataset I have.
If I wanted to get smarter, and have a way of calculating the 'invisible' value even if the data is being filtered in the vizualisation as follows:
Month Name Type
| 1 Jan | Bob | Permanent |
| 1 Jan | Fred | Temp |
| 1 Jan | Mary | Permanent |
| 4 Feb | Bob | Permanent |
| 4 Feb | Fred | Temp |
| 4 Feb | Anne | Permanent |
| 3 Leavers | Mary | Permanent |
| 2 Joiners | Ann | Permanent |
| 3 Leavers | 1. Invisible | x |
| 2 Joiners | 1. Invisible | x |
I thought I could then use Measures to calculate how many people were in each month:
and then bring those measures back into the table using a calculate column to calculate the count
| 1 Jan | Bob | Permanent | 1 |
| 1 Jan | Fred | Temp | 1 |
| 1 Jan | Mary | Permanent | 1 |
| 4 Feb | Bob | Permanent | 1 |
| 4 Feb | Fred | Temp | 1 |
| 4 Feb | Anne | Permanent | 1 |
| 3 Leavers | Mary | Permanent | 1 |
| 2 Joiners | Ann | Permanent | 1 |
| 3 Leavers | 1. Invisible | x | 3 |
| 2 Joiners | 1. Invisible | x | 3 |
Which would be filterable in the vizualization :
So when I remove 'Temporary' from the filter, it dynamically re-calculates the invisible values for Jan and Feb.
But the combination of Measures and Calculated column doesn't seem to work.
If anyone could put me on the right track?
14 Replies
- ghdunn
Helper III
Hi Sturla,
Thanks for responding.
I think that is a simple sample data set in the OP - I don't think it needs to be any more complicated than that.
I am trying to visually compare headcount one month over another and show how many people have joined, and how many have left. I could do that with a normal waterfall if it was one dimensional. However, I want to be able to visualise different groups of 'Types'. To do that in a waterfall style requires me to calculate how many people were in there in Jan, and then in Feb. Again...that is no problem using CountRows. However, I haven't worked out how to write another measure which acts on each row of data. Hence my use of Calculated Column which as you say is bogus.
What would the syntax of a measure be that replicated the logic of my effort, but did so in a measure?
Gerald
- sturlaws
Resident Rockstar
Ok, I finally got what you are trying to do. But. Will your data only contain data for january or february? Because hard coding this works in a simple data set like this, but what happens when you have 2 years worth of data? How should it be displayed?