Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik and ServiceNow Partner to Bring Trusted Enterprise Context into AI-Powered Workflows. Learn More!
cancel
Showing results for 
Search instead for 
Did you mean: 
ziabobaz
Creator III
Creator III

double aggregation in one formula?

Hello,

I have DATA table: ORDER with corresponding STATUS. Status is DUAL.

If the last status per order is not equal "order-delivered", than the ORDER is in progress. The maximum status for this order is considered status in progress

I want to know how many statuses in progress I have (in other words, for all my undelivered orders I want to know of which stage they are in at the moment). I have Date dimension, but i will disregard it for simplicity.

I managed to build aggregation table:

 

aggr(
{<
OrderN=
P({<status={"order-created"}>})-
P({<status={"order-delivered"}>})
>}
max(status),OrderN)

But I can't figure out how to build the table, 'what i need'

I need it in this exact way as in screenshot (with one Dimension = status, and one Measure).

Is it possible?

Thank you

Screenshot_4.jpg

14 Replies
ziabobaz
Creator III
Creator III
Author

Max,

When I select Status dimension, the whole adjusted formula above( your's formula ) collapses.

Any idea why this is happening?

Anonymous
Not applicable

Думаю да, я в курсе. В выражении в set analisys нужно добавить status=,

sum(

    Aggr(

        If(status =  Max({< status=, ................... ) >} TOTAL <OrderN> status) , 1, 0)

    , OrderN, status)

)

чтобы выборка по status не влияла на определение максимального значения

Anonymous
Not applicable

Можно было бы сделать так

sum({< сюда выносим весь остальной set analisys >}

    Aggr(

        If(status =  Max({1} TOTAL <OrderN> status) , 1, 0)

    , OrderN, status)

)

, но тогда максимальный статус перестанет реагировать на любые выборки, в том числе и на период. Что может не совсем отвечать требованиям, если, скажем, нужно посмотреть на состояние в прошлом, отфильтровать заказы или еще что-то. Тогда добавим туда Дата = p(Дата) или Дата = $::Дата (почти то же самое), и по любой выборке по необходимости

sum({< сюда выносим весь остальной set analisys >}

    Aggr(

        If(status =  Max({1< Дата = p(Дата) >} TOTAL <OrderN> status) , 1, 0)

    , OrderN, status)

)

Я не знаю всей модели данных, но вариантов несколько и нужно выбрать наиболее подходящий.

ziabobaz
Creator III
Creator III
Author

Max,

I ended up with the following:

Screenshot_24.jpg

IF in this example sorts out only those records which are equal to the selection in Status.

It is sort of compensation for the {<status=>} I had to put in set analysis in order to build the table contating all data, on which I susbequently aplied above()


That's what I finally have built:


Screenshot_22.jpg


Screenshot_25.jpg


Спасибо за помощь, я 4 дня мучился ))

Anonymous
Not applicable

You are welcome))