Forum Discussion
Applicable88
Impactful Individual
5 years agoCount Ordernumbers base on duplicate value
Hello, I have following table: Ordernumber Date Status 8888 25.04.2021 A 7777 25.04.2021 A 1111 25.04.2021 A 1111 25.04.2021 D 2222 25.04.2021 A 2222 25.04.2021...
- 5 years ago
Hello Applicable88
A measure like this should work:
Performance = VAR Orders_D = CALCULATETABLE ( VALUES ( Orders[Ordernumber] ), Orders[Status] = "D" ) VAR Orders_A = CALCULATETABLE ( VALUES ( Orders[Ordernumber] ), Orders[Status] = "A" ) RETURN COUNTROWS ( EXCEPT ( Orders_D, Orders_A ) )The logic is to take the set of Orders with Status D and remove Orders with Status A using EXCEPT. Any orders with Status A but not Status D will not influence the result.
With your sample data,
- Orders_D = { 1111, 2222, 3333, 4444, 5555 }
- Orders_A = { 1111, 2222, 3333, 7777, 8888 }
- EXCEPT ( Orders_D, Orders_A ) = { 4444, 5555 }
Regards,
Owen
OwenAuger
Super User
5 years agoHello Applicable88
A measure like this should work:
Performance =
VAR Orders_D =
CALCULATETABLE (
VALUES ( Orders[Ordernumber] ),
Orders[Status] = "D"
)
VAR Orders_A =
CALCULATETABLE (
VALUES ( Orders[Ordernumber] ),
Orders[Status] = "A"
)
RETURN
COUNTROWS ( EXCEPT ( Orders_D, Orders_A ) )
The logic is to take the set of Orders with Status D and remove Orders with Status A using EXCEPT. Any orders with Status A but not Status D will not influence the result.
With your sample data,
- Orders_D = { 1111, 2222, 3333, 4444, 5555 }
- Orders_A = { 1111, 2222, 3333, 7777, 8888 }
- EXCEPT ( Orders_D, Orders_A ) = { 4444, 5555 }
Regards,
Owen
Applicable88
Impactful Individual
5 years agoThank you again OwenAuger .
I found the problem. My last function was not right. A simple sum was enough and afterwards it worked out.
Best.