cancel
Showing results for 
Search instead for 
Did you mean: 

Counter with condition

Former Member
0 Kudos

Hello all,

For a customer requirement, i need to count PO (EKPO) linked to Invoices (RSEG) but only if it's linked.

I have a calculation view linking EKPO to RSEG but with an outer join so i have records with populateed PO number (EBELN) and blank Invoice number (EBLNR).

So here i need to do sothing like this :

IF EBELN  and BELNR populated put 1 in the counter

IF EBELN populated and BELNR is null put 0

And also i want to count the same EBELN only once even if it's linked to many BELNR.

Thank you very much

Soufiane

Accepted Solutions (0)

Answers (1)

Answers (1)

former_member226419
Contributor
0 Kudos

Hi,

Create one calculate column name as 'Counter' .

Apply condition as below:

if("EBELN" != ' ' and "BELNR" != ' ',1,if("EBELN" != ' ' and "BELNR" = NULL,0,' '))

BR

Sumeet

Former Member
0 Kudos

Hello Sumeet,

Thank you for help.

I've already tried this but in aggregation it doesn't do the job as a count distinct, so i have a wrong result.

Former Member
0 Kudos

Hi Sufiane,

You can achieve this with 2 step process.

1) Create a calculated column with the below condition

if(isnull("BELNR"),0,1) 

Note:  you don't need to use EBELN in condition because your condition checks just BELNR value.

2) Create counter on calculated column. -- This does distinct count

Right click on 'Calculated Column' folder and select 'Counter' option. select column as calculated column.

Counter is only available in aggregation node in calculation view.

Regards,

Venkat N.

Former Member
0 Kudos

Hello Venkatesh,

Thank you for your reply.

This solution is not working actually, i tried it also because it will count some orders (EBELN) twice or more if they are linked to more than one invoice (BELNR).

Example :

EBELN    EBELP   BELNR   CALCULATED    COUNT DISTINCT

A             B            C            1                        1

A             B            NULL      0                        1

A             B            D            1                        1

When aggregation :

CALCULATED         COUNT DISTINCT

2                              2

The result expected for count distinct is 1 because i want to count the orders (EBELN) linked to invoices (BELNR) only once.

Former Member
0 Kudos

Hi

I did replicate your scenario in my system and it works as expected.

Please check the below image.

I hope you have selected EBELN as attribute counter.

Regards,

Venkat N.