I’m trying to get a distinct count of PRE_FILTER values based on a condition.
Even when I simplify the calc to the most basic of levels, I cannot get distinctCountOver() to work with any ifelse() condition in the first argument.
I’ve even tried the following and still get a SQL exception when it’s added to a table grouped by Field1: distinctCountOver(ifelse(1=1,1,1), [{Field1}], PRE_FILTER)
Field1 is a simple string value in the dataset itself.
Doing countOver(ifelse(1=1,1,1), [{Field1}], PRE_FILTER) does not cause any errors. But for my use case I need a distinctCount, and I need the ifelse statement.
It’s been awhile since we last heard from you on this thread; are you still encountering the same issue or were you able to find a work around in the interim?
Is your visual presenting you with an error that’s something like ‘visual calc reference missing? If that’s the case; this error is normally caused by not including a specific field in your visual that’s being utilized in the calculated fields. Make sure that all fields used in the calculation are also added to your table, if you don’t want/need those columns, you can ‘hide’ them from the visual.
Let me know if that works for your case or if you have any additional questions. If we do not hear back within the next 3 business days, I’ll close out this topic.
@Brett I found a work around by essentially moving all the filters that were in the visual into calculated fields with parameters instead, omitting the need for a PRE_FILTER LAC and was able to use distinct_count instead (which was really annoying but it worked).
However, I wouldn’t call the issue “fixed” since still occurs when I use any ifelse in distinctCountOver.
Here’s an example when I test the same calc using countOver vs distinctCountOver.
trial_sf_id is a UUID text field directly from the database with no nulls.
But when I add them to visuals (any type, kpi, table, it doesn’t matter), distinctCountOver always throws a SQL exception error (not a ‘visual calc reference missing’ error).
Following up here as it’s been awhile since last communication took place on this thread; were you able to create a support ticket and if so, were they able to assist further with this potential bug?
If we do not hear back within the next 3 business days, I’ll close out this topic.