Forum Discussion
Need help with Measure for Matrix Table and Top 5
- 3 years ago
Have you tried sorting by the sum measure in descending order?
- 3 years ago
I would go for:
Ref =
[Sum of Total Gross Incurred] * 1000000000000 + COUNT(LossRunToExcel[Reporting Location City]) - 3 years ago
I got the first example to work in main file. Thank you for all the help. I will need more time this weekend to try the more creative and visual 2nd option.
- 3 years ago
Yes, it's definitely an issue in the service. You need to sort by the city field to get the axis to respect the structure:
It actually emulates the problem we used to have in Desktop when you turned off concatenate fields: for the setting to take effect, you needed to sort the axis by the fields:
It might be worth reporting the issue on the issues forum:
Ok, I've been playing around with the clustered column chart and this is what I have so far:
Change the [Sort measure] to:
Sort measure =
VAR _FreqByCity =
CALCULATE (
[Count Frequency],
FILTER (
ALL ( InjuryCause[Cause Grouping] ),
[Top 5 by frequency and Incurred] < 6
)
)
VAR _LN =
LEN (
FORMAT (
CALCULATE (
[Count Frequency],
ALL ( 'LossRunToExcel'[Reporting Location City] )
),
"text"
)
)
VAR _Pre =
_FreqByCity
* POWER ( 10, _LN * 2 )
VAR _Inc =
CALCULATE (
RANKX (
ALLSELECTED ( LossRunToExcel[Reporting Location City] ),
[Sum of Total Gross Incurred],
,
ASC,
DENSE
),
ALLSELECTED ( InjuryCause[Cause Grouping] )
)
VAR _Mid =
_Inc * POWER ( 10, _LN )
RETURN
IF (
ISBLANK ( [Count Frequency] ),
BLANK (),
_Pre + _Mid
+ RANKX ( ALLSELECTED ( InjuryCause[Cause Grouping] ), [Ref],, ASC, SKIP )
)
If you now create the clustered column chart with the default options, adding filters to the filter pane to limit the cities, you can get what you are looking for, albeit it isn't particularly pretty:
If you prefer, you can create a more appealing visual as follows (albeit it might require maintenance, because we need to create a separate table for the legend colours which means if the dataset grows in cause groupings, you will need to update the legend table accordingly)
I've created the legend colour code using DAX as follows:
Legend colour code =
ADDCOLUMNS (
SELECTCOLUMNS (
DISTINCT ( InjuryCause[Cause Grouping] ),
"Lengend Case Grouping", InjuryCause[Cause Grouping],
"Index",
RANKX (
VALUES ( InjuryCause[Cause Grouping] ),
InjuryCause[Cause Grouping],
,
ASC
)
),
"Colour Code",
SWITCH (
[Index],
1, "#0065A2",
2, "#99E3F8",
3, "#F98A3C",
4, "#605F61",
5, "#379810",
6, "#C635A7",
7, "#B90000",
8, "#004B82",
9, "#03B1E4",
10, "#DFBFBF",
11, "#9C4102",
12, "#5F6B6D",
13, "#FB8281",
14, "#D4F6C6",
15, "#4B3FF0",
16, "#A4DDEE",
17, "#B69ECD",
18, "#B687AC",
19, "#28738A",
20, "#E6E6E6",
21, "#168980",
22, "#293537",
23, "#BB4A4A",
24, "#F2F549",
25, "#939600"
)
)
So the problem with this method is that if new "Case groupings" appear, you need to update and add new colour codes in the switch function.
The model is now as follows:
You can now create the same column chart as the default, but leave out the legend. You can use the following measure for the conditional formatting of the columns:
Colour legend =
LOOKUPVALUE (
'Legend colour code'[Colour Code],
'Legend colour code'[Lengend Case Grouping], MAX ( InjuryCause[Cause Grouping] )
)
Create a separate legend using a matrix visual as follows (you will need this measure to filter the values in the legend):
Filter Legend =
VAR _Table =
ADDCOLUMNS (
SUMMARIZE (
LossRunToExcel,
LossRunToExcel[Reporting Location City],
'InjuryCause'[Cause Grouping]
),
"@Rows",
IF (
CALCULATE (
RANKX (
ALL ( LossRunToExcel[Reporting Location City] ),
CALCULATE ( [Count Frequency], ALL ( InjuryCause[Cause Grouping] ) ),
,
DESC,
SKIP
),
ALL ( 'Legend colour code'[Lengend Case Grouping] )
) < 6
&& [Top 5 by frequency and Incurred] < 6
&& NOT ISBLANK ( [Count Frequency] ),
1
)
)
RETURN
COUNTROWS (
CALCULATETABLE (
VALUES ( 'InjuryCause'[Cause Grouping] ),
FILTER ( _table, NOT ISBLANK ( [@Rows] ) )
)
)
Make sure "Maintain layer order is "on" under properties in the formatting pane - it will keep the legend visible once published even if you click on the chart.
And the visual will be interactive based on a selection in the legend:
New file attached
Both samples are still there. I can not figure out why publishing the file changes the saved file example I sent where the city name is in line with all causes at angle. Not looking good like your first example and my file. I thought removing city name might help..
- bdehning3 years agoPost Prodigy
I did report the issue and gave several screen shots of differnces between Desktop and Publishing of Clustered Column Chart with Concatenate Off.
- PaulDBrown3 years agoCommunity Champion
Have you made sure that "concatenate labels" is turned off under the x-axis options for values in the formatting pane?
- bdehning3 years agoPost Prodigy
Yes I did. It's even worse if turned off. Publishing is the issue.
- bdehning3 years agoPost Prodigy
Here is what both look like from your Sample file when published. See how City hops in front of the Cause. How do we adjust the measure to maybe change this or can we?
- PaulDBrown3 years agoCommunity Champion
Yes, it's definitely an issue in the service. You need to sort by the city field to get the axis to respect the structure:
It actually emulates the problem we used to have in Desktop when you turned off concatenate fields: for the setting to take effect, you needed to sort the axis by the fields:
It might be worth reporting the issue on the issues forum:
- bdehning3 years agoPost Prodigy
You are correct, I had to turn Concatenate off for the X-Axis and then sort by the Sort Measure to ge the Desktop file to look right. Unfortunately it loses that when published. I will report.
- bdehning3 years agoPost Prodigy
Paul, here is a screen shot of an account after publishing that has less then 5 locations. Why no line or division between Cities?
- PaulDBrown3 years agoCommunity Champion
It looks like you have lost the option of not concatenating the fields (same issue as we discussed previously)
- bdehning3 years agoPost Prodigy
I tried stacked column chart and same bad results