How to conditional count in MicroStrategy?

3.2k views Asked by At

Trying to perform the below statements in MicroStrategy to no avail.

Count(Distinct case when Insight <> 'Missing' then call_discuss_sk else null end)

and

Count(Distinct case when Quarters_to_this_quarter between 1 and 5 then call_discuss_sk else null end)

current MSTR code looks like below and can confirm that this doesn't work...

Count<Distinct=True, UseLookupForAttributes=False>(ApplySimple("case when #0='Missing' then NULL else #1 END",Insight,[Call Discuss Sk])){~}

Table I'm querying looks like the below

enter image description here

1

There are 1 answers

0
Chris J On BEST ANSWER

so this is how to do it, note that #0 and #1 refer to the fields after the "" statement so in this case #0 = Insight and #1 = [Call Discuss Sk]

ApplyAgg("Count(Case when #0='Missing' then null else #1 end)", Insight, [Call Discuss Sk]){~+}