Deneb - Text Encoding Condition

Hi,

Need some help on adding a “Text Mark” based on conditions in a field (not specified in X or Y axis).

If Field “Extra” = “Added”, would like to have an “A” in both QuarterOne and QuarterTwo circles. If Field “Extra” = “Deleted”, would like to have “D” in each of the circles. I was not sure if can designate off string or needs to be Quantitative to do text conditions.
Test File.pbix (1.5 MB)

Thank you

This is what it looks like with Current Code

image

But would like Audit 2 to be only one with A’s and Audit 3 to be “D”

Hi @luz58.

To get a label in each circle, one way is to use 2 separate text marks.

Here’s an example of the conditional text encoding code I used in each text mark:

  "encoding": {
	"x": {
	  "field": "QuarterOne",
	  "type": "quantitative"
	},
	"text": {
	  "condition": [
		{ "test": "datum['Extra'] == 'Added'", "value": "A" },
		{ "test": "datum['Extra'] == 'Deleted'", "value": "D" }
	  ],
	  "value": ""
	}
  }

Hope it helps.
Greg
eDNA Forum - Deneb Text Encoding Condition.pbix (1.5 MB)

Thank you, that worked well.

Had another one with same file. If I add gridlines to the below visual and I use the “tickBand”: “extent” encoding, can I close off the grids where the title is? Would like to add a line (red line), but not sure it this is possible since these are the tick hashmarks. If this isn’t possible, any workarounds (i.e. moving title within box)?
Test File.pbix (1.5 MB)

image

Hi @luz58

Please do not ask new questions on solved threads. Rather, create a new thread and link to an existing solved thread if applicable.

@EnterpriseDNA , please split this new question into its own thread starting with the above post.

Regardless, I’m sure there are a number of better ways to accomplish what you want, but I’m under severe time restrictions today, so here’s a quick-and-dirty solution.

  • change Y axis to ordinal
  • add 5th mark of type “rule” and hard-code values for X, Y, and Y2
  • add a “labelPadding” key:value pair to the Y axis to indent the “Title” field

Hope this helps.
Greg
eDNA Forum - Deneb Text Encoding Condition - V2.pbix (1.5 MB)