getWhereClause = function (selectedDimensions, excludeDimension) {
	let whereClause = 'true';
	if (excludeDimension) {
		selectedDimensions = selectedDimensions?.filter((d) => d.dimension !== excludeDimension);
	}
	if (selectedDimensions?.length > 0) {
		whereClause = selectedDimensions
			.map((d) => {
				const values = Array.isArray(d.value) ? d.value : [d.value];

				const { validValues, hasNull } = values.reduce(
					(a, v) => {
						if (v === null) {
							a.hasNull = true;
						} else {
							a.validValues.add(`'${v.toString().replaceAll(`'`, `''`)}'`);
						}
						return a;
					},
					{ validValues: new Set(), hasNull: false }
				);
				// "dimension" in ('value', 'from', 'set')
				const valueExpr = validValues.size
					? `"${d.dimension}" in ( ${[...validValues].join(',')} )`
					: '';
				// "dimension" is null
				const nullExpr = hasNull ? `"${d.dimension}" is null` : '';

				return `( ${[valueExpr, nullExpr].filter(Boolean).join(' OR ')} )`;
			})
			.join(' and ');
	}
	return `( ${whereClause} )`;
}
@param {selectedDimension} selectedDimensions
@param {string} [excludeDimension]
@returns {string}