LAC error in calculated field with different grouping keys

I have a single graph with value parameter named _processor_KPI_agg, which is an aggregate function of a calculated field named _processor_KPI that chooses which field to take based on a chosen parameter named KPI.

Below I will just describe how _processor_KPI_agg is defined:

ifelse(
    ${KPI} = "A", avg({_processor_KPI}, [startDateTime]), 
    avg({_processor_KPI}, [endDateTime])
)

Based on the input parameter KPI, it will return an aggregate function grouped by a field (in the case below by startDateTime or endDateTime). The calculated field does not throw any error, but when I place it as value in a graphic I get the following one: the level aware calculation (LAC) aggregate functions inside one visual aggregate functions should always share the same grouping key

I tested this other calculated field and works well:

ifelse(
    ${KPI} = "A", avg({_processor_KPI}, [startDateTime]), 
    avg({_processor_KPI}, [startDateTime])
)

This last calculated field which does not group the aggregate function in the else case also throws a LAC error:

ifelse(
    ${KPI} = "A", avg({_processor_KPI}, [startDateTime]), 
    avg({_processor_KPI})
)

Thanks for your time, any help will be very appreciated!

Hi @albmargar,

What if you rewrite your calculated fields this way? Does it work?

DateField:

ifelse(${KPI} = "A", startDateTime, endDateTime)

_processor_KPI_agg:

avg({_processor_KPI}, [DateField])
2 Likes

Hi @albmargar -
Did @David_Wong 's suggestion work? If so, could you please mark the response as a solution. If not, please provide more details with screenshots of your issue so we can help. Thanks.

Hi @Kellie_Burton, I did a small test with @David_Wong answer and it worked. However, I have not implemented it in my analysis, which is more complex than the test that I did, since I could not spend time on it. Should I mark the answer as the solution or wait until I can spend more time on it?

Today I implemented @David_Wong solution in my project and it worked. Thank you very much for the answer!

1 Like