Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
microwin88x
Creator III
Creator III

Count IDs by Range

Hello,

I have a table with the following fields:

  • Category: A - B - C
  • ID: 001 - 002 - 003
  • Type: Billing - Sales
  • Amount: Amount Value

This is a sample of the table (please use the attached QVW):

CATEGORYIDTYPEAMOUNT
A1Billing5.000
A1Sales10.000
A2Billing10.000
A2Sales20.000
A3Billing15.000
B11Billing1.000
B11Sales2.000
B12Billing2.000
B12Sales4.000
B13Billing3.000
C26Billing5.000
C26Sales15.000
C27Billing10.000
C27Sales25.000
C28Billing15.000

Then I need to summarize the Amount field by Type = Billing (Column 3) and Type = Sales (Column 4) and calculate the % = Billing / Sales (Column 5):

CATEGORYIDBILLINGSALES%
A15000100000,5
A210000200000,5
A315000300000,5
A420000400000,5
A945000450001
A525000500000,5
A840000500000,8
A630000600000,5
A735000700000,5
A1050000800000,63
B11100020000,5
B12200040000,5
B13300050000,6
B14400080000,5
B155000100000,5
B188000170000,47
B199000200000,45
B2010000210000,48
B2111000250000,44
B2212000260000,46
B2313000280000,46
B2414000300000,47
B2515000400000,38
B1660001100000,05
B1770001300000,05
C2920000400000,5
C3025000500000,5
C3130000600000,5
C3235000700000,5
C3445000750000,6
C3340000800000,5
C35500001000000,5
C265000150000,33
C2710000250000,4
C2815000350000,43
C36550001200000,46
C37600001300000,46
C38650001500000,43
C39700001800000,39
C40750001900000,39
C41800002000000,4
C42850002100000,4
C43900002500000,36
C44950003000000,32
C451000004000000,25

I need to count how many IDs I have in the following ranges (grouped by Category):


  • >= 50%
  • < 50% >=30%
  • < 30% >= 20%
  • < 20%

So this would be the final result:

CATEGORYBILLINGSALES%# ID>= 50%< 50%  >=30%< 30%  >= 20%< 20%
A275.000455.00060,44%1010000
B120.000476.00025,21%155802
C1.050.0002.680.00039,18%2071210
Total1.445.0003.611.00040,02%45222012

Is there any way to do that?

Thank you!!!

1 Solution

Accepted Solutions
andrey_krylov
Specialist
Specialist

Hi, you can try this solution

Sum( If( Aggr(SUM({< TYPE={'Billing'} >} AMOUNT) / SUM({< TYPE={'Sales'} >} AMOUNT) , ID) >= 0.5, 1) )

View solution in original post

2 Replies
andrey_krylov
Specialist
Specialist

Hi, you can try this solution

Sum( If( Aggr(SUM({< TYPE={'Billing'} >} AMOUNT) / SUM({< TYPE={'Sales'} >} AMOUNT) , ID) >= 0.5, 1) )

MarcoWedel