Mismatched Aggregation in comparing current and previous one

I have many stratas in the different years and with different broker. How can I compare the current broker with the previous one? It always show an mismatched aggregation, how can I fix it?

Hi @rebecca000827

Welcome to the Quick Sight community!

Use the lag function to compare the current value to previous value.

If you are trying the Period Over Period calculations, Please refer to the below Quick Sight community post this might be helpful for you.

1 Like

Thanks! but what I try to compare this the previous string value with the current string value, so lag() always gives me the mismatched aggregation. in addition, I don’t wanna compare this year with last year, but this current data with last data(sometimes there are gap between records)

Hi @rebecca000827

lag function cannot be used with dimensions as the first argument.

Could you please explain your requirements in detail with sample data and what you are trying to achieve? This could help us find a solution.

I have some information about the strata and its insurance records. some strata have few insurance records in different years, for example, 2022 from company A, 2023 from company B, 2025 from company C.
I try to flag those record when the strata change their broker, for example, from A to B, or B tp C. I want to flag all those changes to analyze why they change.
i always encounter the mismatched aggregation error and don’t know how to compare the current data with the previous data

Hi @rebecca000827

Apologies, dimension field works with the lag function. But it can’t be used it with ifelse function to compare.

Example:

lag(
    Broker,
    [Year ASC],
    1,
    [StrataID]
)

1 Like

thanks! is there any other way we could identify the previous one and compare and mark it if it changes different from the current one?

Hi @rebecca000827

The lag function cannot be compared directly with a non-aggregated field, and it cannot be used within an ifelse function.

Please preprocess the data using a SQL database if you need to compare broker changes.

Hi @rebecca000827,
It’s been awhile since we last heard from you, did you have any additional questions regarding your post?

If we do not hear back within the next 3 business days, I’ll close out this topic.

Thank you!

Hi @rebecca000827,
Since we haven’t heard back, I’ll go ahead and close out this topic. However, if you have any additional questions, feel free to create a new post in the community and link this discussion for relevant information if needed.

Thank you!