Forum Discussion
Dates improperly aggregating in visualization
- 9 years ago
A few things you need to fix.
1. My example of using a number (1-12) was an example if you have a Month column. Since you are using Month and Year, you need to make a unique order column for this value. I would make a calc column (query editor) that takes Year*100+Month. This will give you values like 201601 for Jan2016, 201602 for Feb2016 etc. Make sure the data type is numeric and this will allow you to sort correctly across multiple years.
2. You don't need to concantenate this unique sort order column with the Month Year column. Just select the field from the fields list, go to the Modeling tab, and choose Sort By > Unique Sort Order column.
Hi Viper1o34,
I am not able to view your image.
However, in your scenario, you can create the following columns, replace 'Date' table and 'Date'[DateKey] column with your owns in the DAX formulas below.
MonthNumber = MONTH('Date'[DateKey])
Year = YEAR('Date'[DateKey])
Month = SWITCH([MonthNumber],
1,"Jan",
2,"Feb",
3,"Mar",
4,"Apr",
5,"May",
6,"Jun",
7,"Jul",
8,"Aug",
9,"Sep",
10,"Oct",
11,"Nov",
12,"Dec",
"Invalid Month Number"
)
MonthYear = CONCATENATE('Date'[Month],CONCATENATE(",",'Date'[Year]))
This way, you can put the MonthYear into Axis and get your expected result.
Thanks,
Lydia Zhang
Lydia,
Is there a video I can look at regarding the formulas? In your first formula example
MonthNumber = MONTH('Date'[DateKey])
I dont know what a "date key" is or how it should be used. Also when creating this there is not more than a single table. In the background data there is only one spreadsheet that contains the information I need. I do not have a seperate "Date" table that has a relationship with the ticket numbers I am counting. Do I need to create one?
In the forums I have seen many users referring to multiple tables. I come from using Tableau where I could simply drop and drag the data or write a simple formula.
Also is there a help number I can call here? There is nothing online where I can talk to a real person to troubleshoot small issues like this. If there is please PM me.
- Vvelarde9 years agoCommunity Champion
- Viper1o349 years agoRegular Visitor
In the screenshot below my January 2016 and 2017 data is being aggregated together. I want two January columns of different colors for each sepearate year. Sample data included. No way to attach anything here and there are too many rows to display in this forum.
Change Summary Customer Status Reported Date CH10000007 Change CLOSE 6/30/16 4:27 AM CH10000008 Change,Application,Must Select CI CLOSE 7/1/16 6:33 AM CH10000009 Change CLOSE 7/1/16 9:14 AM CH10000011 Change,Hardware-Mainframe CLOSE 7/1/16 9:17 AM CH10000014 Change,Application,Must Select CI,Password - System ID CLOSE 7/5/16 8:40 AM
- Anonymous9 years agoNot applicable
Hi Viper1o34,
You don't need to create other tables, just right click your table in Report view, then select "New Column" to create calculated olumns using the following formulas.MonthNumber = MONTH('Tablename'[Report Date])
Year = YEAR('TableName'[Report Date])Month = SWITCH([MonthNumber],
1,"Jan",
2,"Feb",
3,"Mar",
4,"Apr",
5,"May",
6,"Jun",
7,"Jul",
8,"Aug",
9,"Sep",
10,"Oct",
11,"Nov",
12,"Dec",
"Invalid Month Number"
)MonthYear = CONCATENATE('TableName'[Month],CONCATENATE(",",'TableName'[Year]))
Then put MonthYear into Axis of your visual.
Or you can use Vvelarde's method to create your visual.
Thanks,
Lydia Zhang- Viper1o349 years agoRegular Visitor
Lydia,
Thank you for the help. I have entered the formulas as you described them and I am still not yet to the result I need. The visualization is not properly separating the years by color. It is also not creating a new column for the new year. Rather than a stacked bar graph my goal was to have each separate month as its own bar.
For some reason it is improperly counting. December ONLY has 2016 tickets. Since we have not yet made it to December 2017 its strange it is separating this out. I do not know why it is wanting to separate December and November as these are not the correct months for the distinct color.
How do I create a chart that reads Jan 2016, Feb 2016, Mar 2016 ... Jan 2017 without stacking the colors? Also this new chart is missing data.
Specifically using the formula you provided I have September and June in the data but missing in the visiualization. Its simply ommiting these months entirely. I will provide examples from the report view below.
Current visualization:
Missing Data (June only has one entry but still it should be in the bar graph):
Lastly these bars are not in monthly order. Rather, it is defaulting to Alphabetical order. This is confusing for a viewer and I must have these in the order of the month rather than Alphabetical.
Thank you for the help so far and hopefully I can get this corrected.
Brian
- dkay84_PowerBI9 years agoMicrosoft Employee
You need to put [MonthYear] as the axis. If you have months with no data, they will not be shown by default, but by clicking on the drop down arrow on the field (in the Visuals pane) you can turn on showing values with no data. To sort string values (text) in a non alphabetical way, you need to make a column that has the sort order. So, if you make a table that has month name Jan...Dec, you would need a column that has 1...12 for the months. Then, if you select the month name field and go to the Modeling tab, you can choose "Sort By" and choose the order column.