no data, labels and small multiples

Hello,

I have a small multiples, with one data label inside the small multiples (thus repeated multiple times).
It displays a percentage (named rate) with brackets around it. The text is thus ([rate]).

Sometimes there is data, sometimes not (ie. rate is null). When there is no data, the brackets are always there, no matter what I do about null values (source/full/ignore).

Is there a way to not display anything if there is no data?

I tried to add a no data script to the label but it never kicks in (it only consists of debugger;) so I am extra confused. I am not sure how it could work for a small multiple anyway (the script name is probably duplicated, so I don’t know ho to target labels only without data).

Thanks,

On a side note, I tried to source with a custom value (0) and then apply a state (is rate is 0, font color is white) but this has absolutely no effect.

If on the other hand, I source with explicit zero from the dropdown, I get the result I expect.

I could live with that, but my labels will become more complex (include image) and playing with font color would not work in that case. I would love to find more generic way to do what I am looking for.

Hi,

You can use measure formatting in the Data Analysis Panel to add the parentheses, and then they can only be visible if the measure actually has a value. A custom format of “(0)” does this, or use “(0,0)” to include thousands separators.

Otherwise, if there is any measure with a cell corresponding with that small multiple cell, either from the data source or a missing data rule outputting anything other than “None”, the entire small multiple cell will be there including all of its data labels. (If the entire small multiple cell should be blank instead, you could check the small multiple’s Data Analysis Panel and all of its measures. Data Preview can show you the measure values.)

There isn’t a dedicated way to remove unwanted parentheses if you set them in the data label’s Text property, but states should work. Trying to use states to find a match with a missing or empty value is probably leading to trouble, but there are other options. I’m not sure what you mean by sourcing custom vs. explicit zeros, but using a missing data rule to output zeros and using states to match with this does work if zeros should be hidden. Or you could reverse the conditions of your state and use a state style to make text only visible if there is a value (add a state for the measure with no conditions). State styles can change the background and font color and soon will be able to customize the text itself for data labels.

Hi Jamie,

Thanks, that’s a lot of information in there.

You can use measure formatting in the Data Analysis Panel

This sounded awesome, I never noticed custom formating before. It works with brackets and numeric ((0) or (0,0)), with basic percentages (P0, P1), but if I add any other character to a percentage format, eg. (P0) then I have ( and P literally displayed. Following the docs does not help.

if there is any measure […] outputting anything other than “None”,

That is indeed what I am looking for, the cell must be displayed, it’s only a part of it (one label only) which I want to have not displayed, so that’s good.

Or you could reverse the conditions of your state and use a state style to make text only visible if there is a value

That’s a good trick. The issue I have with states is that it is only about the content text. I cannot hide a full item.

That is why I tried to apply a no-data script. Is it at all possible within small-multiples?

P0 and P1 are standard formats that are only specified with one letter and one number and from there they display based on the user’s culture. Custom numeric formats are separate: https://docs.microsoft.com/en-us/dotnet/standard/base-types/custom-numeric-format-strings. To add a percent sign and multiply the number by 100, you can just add the symbol to the custom format: (0,0%) To add it without multiplying the number by 100, use single quotes: (0,0'%')

I can’t picture how states aren’t helping if you can change the image background, border and text based on the same conditions, but if you were to use script, that’s going to be possible in the data changed actions where you can check for whatever conditions you’re interested in even when there are rows and columns in the data result:

var cellset = this.metricSetBindings[0].dataResult.cellset;
if (!cellset || !cellset.cells[0] || !cellset.cells[0][0] || cellset.cells[0][0].value == null) {
  this.hidden = true; 
}

The format you showed does the trick for me. That’s good enough for me for now.
Thanks for your help!