Forum Discussion
Stacked bar graph question
- 2 years ago
The first part is simple - you can use the implicit measures
For the second part ( the chart ) you need a couple of things - for a proper implementation you need a calendar table for the X axis, and then a measure for the mapping. Or you can cheat and create a calculated table that materializes the prior result. This can be done by "borrowing" the DAX code from the visual
and cleaning it up as
Table2 = SUMMARIZECOLUMNS( 'Table'[PIN], 'Table'[animal_state], "MinConfirmed_Date", CALCULATE(MIN('Table'[Confirmed Date])) )Then you can render your column chart.
or in categorical axis
see attached
Let's say the data looks like this. I want to know the earliest confirmed date for a given animal_state. I also want to know the earliest confirmed date for a given PIN, but I'll start with animal_state because I think that may be simpler.
| PIN | animal_state | Confirmed Date |
| ABC | MN | 1/1/2024 |
| ABC | MN | 1/2/2024 |
| AAA | MN | 1/3/2024 |
| AAA | MN | 1/3/2024 |
| AAA | MN | 1/5/2024 |
| AAA | MN | 1/6/2024 |
| AAD | MN | 1/7/2024 |
| AAD | MN | 1/5/2024 |
| AAD | MN | 1/5/2024 |
| BAD | MI | 1/6/2024 |
| BAD | MI | 1/7/2024 |
| BAD | MI | 1/8/2024 |
| BAD | MI | 1/15/2024 |
| BAD | MI | 1/15/2024 |
| BCD | MI | 1/14/2024 |
| BCD | MI | 1/8/2024 |
| CBA | KS | 2/4/2024 |
| CBA | KS | 2/16/2024 |
| CBA | KS | 2/16/2024 |
| CBA | KS | 2/16/2024 |
| CBA | KS | 2/16/2024 |
| CBA | KS | 2/17/2024 |
| CBA | KS | 2/18/2024 |
| CBA | KS | 2/19/2024 |
| CBA | KS | 2/19/2024 |
| CCD | KS | 2/20/2024 |
| CCD | KS | 2/21/2024 |
| CCD | KS | 2/7/2024 |
| CED | KS | 2/8/2024 |
| CED | KS | 2/9/2024 |
| CED | KS | 2/8/2024 |
| CED | KS | 2/8/2024 |
| CED | KS | 2/8/2024 |
| CED | KS | 2/8/2024 |
| CRD | KS | 2/9/2024 |
| CRD | KS | 2/10/2024 |
| CRD | KS | 2/10/2024 |
| CRD | KS | 2/10/2024 |
| CRD | KS | 2/10/2024 |
| DED | CA | 3/2/2024 |
| DED | CA | 3/2/2024 |
| DED | CA | 3/2/2024 |
| DED | CA | 4/2/2024 |
| DED | CA | 2/29/2024 |
| DAD | CA | 2/29/2024 |
| DAD | CA | 2/29/2024 |
| DAD | CA | 2/29/2024 |
| DAD | CA | 3/1/2024 |
| DEC | CA | 3/2/2024 |
| DTF | CA | 3/2/2024 |
| DTF | CA | 3/2/2024 |
| DTF | CA | 3/2/2024 |
| DTF | CA | 3/2/2024 |
| EED | TX | 2/4/2024 |
| EED | TX | 2/4/2024 |
| EED | TX | 2/4/2024 |
| EED | TX | 4/3/2024 |
| EED | TX | 4/4/2024 |
| EED | TX | 4/5/2024 |
| EED | TX | 4/6/2024 |
| EAD | TX | 4/7/2024 |
| EAD | TX | 4/7/2024 |
| EAT | TX | 4/7/2024 |
| EAT | TX | 4/7/2024 |
| EAT | TX | 4/2/2024 |
| EAT | TX | 3/15/2024 |
| EAT | TX | 3/15/2024 |
| ERD | TX | 4/7/2024 |
| ERD | TX | 3/15/2024 |
I understand I need the data to be pivoted somehow like this (which I did manually) so I can see the earliest confirmed date per animal_state:
| PIN | animal_state | Confirmed Date |
| ABC | MN | 1/1/2024 |
| AAA | MN | 1/3/2024 |
| AAD | MN | 1/5/2024 |
| BAD | MI | 1/6/2024 |
| BCD | MI | 1/8/2024 |
| CBA | KS | 2/4/2024 |
| EED | TX | 2/4/2024 |
| CCD | KS | 2/7/2024 |
| CED | KS | 2/8/2024 |
| CRD | KS | 2/9/2024 |
| DAD | CA | 2/29/2024 |
| DED | CA | 3/2/2024 |
| DEC | CA | 3/2/2024 |
| DTF | CA | 3/2/2024 |
| EAT | TX | 3/15/2024 |
| ERD | TX | 3/15/2024 |
| EAD | TX | 4/7/2024 |
What I'd like as a final stacked bar graph is something like this:
Thanks.
The first part is simple - you can use the implicit measures
For the second part ( the chart ) you need a couple of things - for a proper implementation you need a calendar table for the X axis, and then a measure for the mapping. Or you can cheat and create a calculated table that materializes the prior result. This can be done by "borrowing" the DAX code from the visual
and cleaning it up as
Table2 = SUMMARIZECOLUMNS(
'Table'[PIN],
'Table'[animal_state],
"MinConfirmed_Date", CALCULATE(MIN('Table'[Confirmed Date]))
)
Then you can render your column chart.
or in categorical axis
see attached