Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
Dear Forum,
I'm running around in circles trying apply a 'Is Not Null' clause in to the following...
Count({$<[Month-Year]=,[Day-Month]=,Date={">=$(=Min(Date))<=$(=Max(Date))"},[Field1]={"Late"}>} [Job Number])
Can anyone put me out of my misery and tell me why this isn't working...
Count({$<[Month-Year]=,[Day-Month]=,Date={">=$(=Min(Date))<=$(=Max(Date))"},[Field1]={"Late"},Len(Trim([Field2]))>0>} [Job Number])
Thanks.
The second expression has an invalid syntax. Set expression is used to define a selection in a specific state of your data. The syntax simple defines how to alter the selection before the aggregation is processed.
Len(Trim([Field2]))>0 does not define a field selection, it is an aggregation and a comparison. What you need to do is find a way to select the records you are interested in.
A simple approach is to generate a flag during data model load. In this case it will create a flag with -1 (true) or 0 (false). For example as;
Len(Trim([Field2]))>0 AS FlgField2HasContent
Then you can easily include the "non empty" values in your aggregation with;
Count({$<[Month-Year]=,[Day-Month]=,Date={">=$(=Min(Date))<=$(=Max(Date))"},[Field1]={"Late"},FlgField2HasContent={"-1"}>} [Job Number])
An other option is that
The second expression has an invalid syntax. Set expression is used to define a selection in a specific state of your data. The syntax simple defines how to alter the selection before the aggregation is processed.
Len(Trim([Field2]))>0 does not define a field selection, it is an aggregation and a comparison. What you need to do is find a way to select the records you are interested in.
A simple approach is to generate a flag during data model load. In this case it will create a flag with -1 (true) or 0 (false). For example as;
Len(Trim([Field2]))>0 AS FlgField2HasContent
Then you can easily include the "non empty" values in your aggregation with;
Count({$<[Month-Year]=,[Day-Month]=,Date={">=$(=Min(Date))<=$(=Max(Date))"},[Field1]={"Late"},FlgField2HasContent={"-1"}>} [Job Number])
An other option is that
Tko's approach is the best one to give you the most flexibility.
However a quick fix could be to have Field2={"*"} in your set analysis which will match anything and by implication not match nulls.
I Think you should go with @ToniKautto solution of creating a flag in the data model then use that in set analysis. An alternate solution would be
Count({$<[Month-Year]=,[Day-Month]=,Date={">=$(=Min(Date))<=$(=Max(Date))"},[Field1]={"Late"},[Field2]={"=len(trim([Field2]))>0"} >} [Job Number])
Try this
Count({$<[Month-Year]=,[Day-Month]=,Date={">=$(=Min(Date))<=$(=Max(Date))"},[Field1]={"Late"},[Field2]-={""}>} [Job Number])
or
If(not IsNull([Field2]),
Count({$<[Month-Year]=,[Day-Month]=,Date={">=$(=Min(Date))<=$(=Max(Date))"},[Field1]={"Late"}>} [Job Number]),0)