How to get the desired total of Random numbers ?
I m in a big problem and want a urgent solution.
I want to randomise numbers with specified limit and the total of all the randomised numbers should be desirable.
e.g. if i m generating random number 24 times in a loop then the total of all the gerenrated numbers should be 100 and each randomised generated number should not be greater than 6.
Please help me out. is there any method from which i can get, desirable total from the gererated random numbers ?
Please help.
thanks in advance
In my usual manner, I'll throw in a couple of ideas and leave others to discard them again :-)
Pick random numbers. If, at some point, the sum goes over 100, throw away the last number at instead put in the number that will make the sum exactly 100. Then put in 0 until you have 24 numbers. Those 0s won't look random. If it helps, shuffle all the numbers so the 0 come in random places in the sequence. If it's still not random enough, discard the whole idea. If, on the other hand, you still are m numbers short of 24 numbers and the sum goes under 100 - (m * 6), in a similar manner stop using randomness and throw in the numbers needed to hit 100. Shuffle to distribute the 6s.
Another idea, there are 100 ^ 24 or 10 ^ 48 ways to put 100 balls into 24 buckets. Find out how many ways there are under the constraint that you can put at most 6 balls into a bucket. Enumerate them, pick one at random and generate it. I would say that this should give you a good randomness, but does it also look that way under your requirements?
Similar Messages
-
How to get the Grand Total in Module pool Screen
Hi Frds.
How to get the Grand Total in Module pool Screen
Example i have 10 different materials
for each matarial has different moving . But in my case matarials is doesnt matter here
10 material Moving Average price to do Frand total and display in one column...
Please Help me out Frds.
Regards,
KabilHi
You need to calculate the total in a module of PAI (or PBO) event:
PROCESS PAI.
LOOP.....
ENDLOOP.
MODULE CALCULATE_TOTAL.
MODULE CALCULATE_TOTAL.
GRAND_TOTAL = 0.
LOOP AT ITAB,
GRAND_TOTAL = GRAND_TOTAL + ITAB-PWB.
ENDLOOP.
ENDMODULE.
In this way the grand total will be calculated as soon as the user presses enter or another command.
You can't insert the calculation in the loop of table control, because this loop runs the visible lines only, so it's better to calculate the total out of those loop, -
HOW TO GET THE GRAND TOTALS IN ALV USING GRID FM
Hi,
I would like to know that am getting the sub totals using the ALV_GRID FM,
But I need Grand totals how i can get and what is the paramater to keep = x to get this Grand totals\.Hi,
If you have the DO_SUM = 'X' in the field catalog internal table for the corresponding column..Then you will get the grand total..
Thanks,
Naren -
How to get the sum total of just one row in the dashboard
How do I get the sum total of one row in the compound layer results. This is 11g
Does anyone know?
may be sales, I need the total at the bottom of the row..
thx
ChuckI fnd the answer,
in the table view, click edit then nxt to the columns and measures there is total sum icon. Click that, and choose after -
How to get the measure total at row level for another measure calculation in DAX?
Hi There,
Using DAX, I am trying to get an expression for a calculated measure as follow:
So basically, I would like to get the AMeasure total highlighted in yellow in the A2Measure calculation:
Smeasure -(Ameasure total * WMeasure) where Ameasure total is the one highlighted.
I think my question would be how to get the total of a measure in order to used in the calculation of another measure.
Thanks and best regards,
JossHi Joss83,
If you're trying to get the result for [AMeasure] at the total level (i.e. 5.09 in your example) you can do this by creating a version of this measures that is evaluated after ignoring the filters (indirectly or explicitly) placed on
the 'Customer' and 'Player' columns. You may also need to ignore the filters place on some other tables or columns that must be ignored in order for the correct total to be returned.
Without knowing much more about your data model, I can only take a vague guess as to what this calculation would look like in your scenario:
AMeasureTotal:=
CALCULATE(
[AMeasure],
ALL(Customer[Customer]),
ALL(Player[Player])
You can read more about the 'ALL' DAX function here:
http://technet.microsoft.com/en-us/library/ee634802.aspx
Hope this helps,
Michael -
How to get the group totals in report
HI,
Iam generating a report to display Storage Location, and Unit of Measures and Material group and also group totals.
how to display the group totals on the report.
thank q
rushi.Hi,
This following report clearly explains how to display the subtotal and grand total of
the particular field in alv.
REPORT YMS_ALVSUBTOTAL.
*REPORT z_alv_sub_totals .
TYPE-POOLS: slis.
DATA: BEGIN OF it_output OCCURS 0,
var1(8) TYPE n,
var2(10),
var3 TYPE I,
END OF it_output.
DATA: it_fieldcat TYPE slis_t_fieldcat_alv,
t_fieldcat TYPE slis_fieldcat_alv,
it_sort TYPE slis_t_sortinfo_alv,
t_sort TYPE slis_sortinfo_alv,
v_repid LIKE sy-repid.
INITIALIZATION.
v_repid = sy-repid.
START-OF-SELECTION.
PERFORM get_data.
PERFORM sort_fields.
PERFORM fill_fieldcat.
PERFORM list_display.
*& Form GET_DATA
text
--> p1 text
<-- p2 text
FORM get_data.
it_output-var1 = 1000.
it_output-var2 = 'anupama'.
it_output-var3 = '10000'.
it_output-key = 'X'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 1000.
it_output-var2 = 'siddhu'.
it_output-var3 = '20000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 1000.
it_output-var2 = 'chinni'.
it_output-var3 = '100000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 2000.
it_output-var2 = 'chicchu'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 2000.
it_output-var2 = 'candy'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 1000.
it_output-var2 = 'anupama'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
it_output-var1 = 4000.
it_output-var2 = 'anupama'.
it_output-var3 = '10000'.
APPEND it_output.
CLEAR it_output.
ENDFORM. " GET_DATA
*& Form fill_fieldcat
text
--> p1 text
<-- p2 text
FORM fill_fieldcat.
PERFORM fill_fields USING: 'IT_OUTPUT' 'VAR1' 'Variable 1' ' ',
'IT_OUTPUT' 'VAR2' 'Variable 2' ' ',
'IT_OUTPUT' 'VAR3' 'Variable 3' 'X'.
ENDFORM. " fill_fieldcat
*& Form fill_fields
text
-->P_0146 text
-->P_0147 text
-->P_0148 text
-->P_0149 text
FORM fill_fields USING value(tabname) TYPE slis_tabname
value(fieldname) TYPE slis_fieldname
value(seltext_m) LIKE dd03p-scrtext_m
value(do_sum) TYPE c.
t_fieldcat-tabname = tabname.
t_fieldcat-fieldname = fieldname.
t_fieldcat-seltext_m = seltext_m.
IF do_sum = 'X'.
t_fieldcat-datatype = 'CURR'.
ENDIF.
t_fieldcat-do_sum = do_sum.
APPEND t_fieldcat TO it_fieldcat.
CLEAR t_fieldcat.
ENDFORM. " fill_fields
*& Form list_display
text
--> p1 text
<-- p2 text
FORM list_display.
CALL FUNCTION 'REUSE_ALV_LIST_DISPLAY'
EXPORTING
i_callback_program = v_repid
it_fieldcat = it_fieldcat
it_sort = it_sort[]
TABLES
t_outtab = it_output
EXCEPTIONS
program_error = 1
OTHERS = 2
IF sy-subrc <> 0.
MESSAGE ID SY-MSGID TYPE SY-MSGTY NUMBER SY-MSGNO
WITH SY-MSGV1 SY-MSGV2 SY-MSGV3 SY-MSGV4.
ENDIF.
ENDFORM. " list_display
*& Form sort_fields
text
--> p1 text
<-- p2 text
FORM sort_fields.
t_sort-fieldname = 'VAR1'.
t_sort-tabname = 'IT_OUTPUT'.
t_sort-spos = 1.
t_sort-up = 'X'.
t_sort-subtot = 'X'.
APPEND t_sort TO it_sort.
CLEAR t_sort.
t_sort-fieldname = 'VAR3'.
t_sort-tabname = 'IT_OUTPUT'.
t_sort-spos = 2.
t_sort-up = 'X'.
APPEND t_sort TO it_sort.
CLEAR t_sort.
ENDFORM. " sort_fields
Thanks,
Sankar M -
Hello BW gurus,
sorry for the incomplete question.
This is how i need my report.
Account Number Key Figure Type Company code Plant Sales Organization Fiscal year/period Z1/007.2006 Z1/008.2006 Z1/009.2006 Z1/010.2006 Z1/011.2006 Z1/012.2006
SALES x1
SALES x2
SALES x3
SALES x4
SALES x5
SALES x6
Overall Result SALES x1x2..x6
Similarly i need to get the cost of sales and its overall results
and then i have to get the gross margin as (Sales - Cost of Sales) for each fiscal period(columnwise).
i got the Sales and Cost of Sales like this
Plant Sales Organization Fiscal year/period
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
SALES
COST OF SALES
GROSS MARGIN
but i need all the sales data first and its total(S)
and then all the cost of sales data and its total(C)
and the gross margin (S-C) for individual fiscal period.
Please reply ASAP.Quick help is appreciated.
Thanks in advance,
Regards
Sam MathewHi Viraylab,
check <b>VBAP-NETPR</b> field of table <b>VBAP</b>
It gives the net price corresponding to a line item.
Goto Tcode VA03.See the <b>item overview</b> tab U will get <b>Net Price</b> field for indivisual line item.
Reward points if helpful.
Regards,
Hemant -
How to get the max total sale by date on every store
I am trying to write a query in Oracle which will return both the store_id and the maximum total sale by date
Hi,
Whenever you have a question, please post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all the tables involved, and the results you want from that data.
Explain, using specific examples, how you get those results from that data.
Always say what version of Oracle you're using (e.g. 11.2.0.2.0).
See the forum FAQ: https://forums.oracle.com/message/9362002#9362002
Hjava wrote:
I am trying to write a query in Oracle which will return both the store_id and the maximum total sale by date
Do you mean you want to see the store_id that had the maximum total sale?
In general, this can be done with a Top-N Query, using an analytic function such as RANK. For an example, see http://forums.oracle.com/forums/thread.jspa?messageID=3739610
If you only want the date, the maximum total from that date, and 1 column from the same row with the maximum (e.g. store_id), then you might be able to use the aggregate LAST function instead.
What results do you want in case of a tie? (That is, if 2 or mote store_ids have the same total sale on a given date, and no other store_id has a higher total.) -
How to get the desired output in the format ...?
Hi all,
I am having data like this.
Col1 col2 col3
1 2 1
1 2 2
1 2 3
2 3 7
2 3 8
2 3 9
I want to output the data like this
1 2 1,2,3
2 3 7,8,9
How to get this.
Thanks in advance,
PalIn simple sql...
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
SQL> select * from t
2 /
COL1 COL2 COL3
1 2 1
1 2 2
1 2 3
2 3 7
2 3 8
2 3 9
6 rows selected.
SQL> select max(decode(rno,1,to_number(col1||col2||col3))) col1, max(decode(rno,2,col3)) col2, max(decode(rno,3,col3)) col3
2 from (select row_number() over(partition by col1,col2 order by col3) rno, t.*
3 from t)
4 group by col1
5 /
COL1 COL2 COL3
121 2 3
237 8 9
SQL>Thanks,
Karthick. -
How to get the grand total ?
Hi all,
I got 1 main query say Q1 link to another 3query, Q2, Q3 & Q4. In Q2, Q3 & Q4, I got the difference qty display based on individual repeating frame. Now if I need to sum the grand total of Q2, Q3 & Q4 ? how should I do ?
I try to put the sumary up in Q1, but the system has given REP-1517 error.
Any idea please help me. Thanks.
Rgds
LimAdd summary columns in your data model. Where to put them exactly depends on your report. E.g. if you want a grand total at the end of the report, you create the column outside the query. The Object Navigator shows a Summary Columns node beneath the Queries node for these columns.
-
How to get the salary total.
Hi Sirs,
i am new to oaf.
in my project i have one number column.
how to displays total of that column plz help me
Thanks
latha.Hi
Those field which appearing on the page where user can enter the value or the field used to display the value are beans like message text input bean ,lov input bean etc
as you said
my field data type is number in query and jdeveloper voso you shud confrim that the field (bean) where you want to enable total value in your table must be set the DataType as number.
Thanks
Pratap -
How to Get the desired Name in Distrubution Lists
Hai all.
In my scenario I come accross distrubution list.
I created sucessfully Distrubution Lists and validated and run in Ofline Wizard and it run sucessfully.
But here comes the issue is the name of the report is which created by distrubution list is appeneded with the username)description of report)and name of report.
but i need a anme in another format can any one help me out....
thanks,
RajeshHi,
Variants are stored in table VARI and VARID.
You can use RS_ALL_VARIANTS_4_1_REPORT to get all the variants for a report program.
please check out the link below it will be helpful to you
Re: Programs for a transaction variant
Hope this helps.
ashish -
How to get the desire output from sql query
Consider an Order Table: ...
Order Table:
Order Id Item Qty
O1 A1 5
O2 A2 1
O3 A3 3
Please provide SQL which will explode the above data into single unit level records as shown below
Desired Output:
Order Id Order Id Qty
O1 A1 1
O1 A1 1
O1 A1 1
O1 A1 1
O1 A1 1
O2 A2 1
O3 A3 1
O3 A3 1
O3 A3 1How do I ask a question on the forums?
SQL and PL/SQL FAQ -
hi friends
i have a field having name value in table which when order by a datetime field named change_date give me the result like shown below
a b value
* * 3
* * 5
* * -1
* * 8
* * 13
* * 19
* * 21
* * -1
* * 6
now i want a query that will give result like below
* * -1
* * 8
* * -1
* * 6
means the record having the value field -1 and the next row and then again -1 record and the next immediate record.Plz help
Edited by: dj on Feb 25, 2012 5:36 AMMaybe
select a,b,value
from (select a,b,value,
row_number() over (order by your_column) rn,
case when lag(value) over (order by your_column) = -1 then 1 end x
from your_table
where value = -1
or x is not null
order by rnRegards
Etbin -
My Table Data
ContractID MaterialGroup CommodityCode Amount
C123 Travel 200 100
C123 Travel 201 100
C123 Travel 203 100
C124 Stationery 315 500
C126 Travel 200 600
C126 Admin 413 600
My expected output
ContractID MaterialGroup CommodityCode Amount
C123 Travel 200|201|203 100
C124 Stationery 315 500
C126 Travel|Admin 200|413 600
My Present Output
CONTRACTID MATERIALGROUP COMMODITYCODE AMOUNT
C123 Travel|Travel|Travel 200|203|201 100
C124 Stationery 315 500
C126 Travel|Admin 200|413 600
My Query:
SELECT ContractID,
RTrim(
xmlagg(
xmlelement(e, MaterialGroup|| '|')).extract('//text()'),'|') MaterialGroup,
RTrim(
xmlagg(
xmlelement(e, CommodityCode|| '|')).extract('//text()'),'|') CommodityCode,Amount
FROM (
WITH t1 AS (
SELECT 'C123' ContractID, 'Travel'MaterialGroup, 200 CommodityCode, 100 Amount FROM dual UNION all
SELECT 'C123', 'Travel', 201, 100 FROM dual UNION all
SELECT 'C123', 'Travel', 203, 100 FROM dual UNION all
SELECT 'C124','Stationery', 315, 500 FROM dual UNION all
SELECT 'C126','Travel', 200, 600 FROM dual UNION all
SELECT 'C126','Admin',413, 600 FROM dual)
SELECT * FROM t1)
GROUP BY ContractID,Amount;select t.*,
case when cdm = 1 and cm > 1
then substr(materialgroup,1, instr(materialgroup,'|', cdm)-1)
else materialgroup end materialgroup_edit,
case when cdm = 1 and cm > 1 then mm else materialgroup end materialgroup_edit2
from
select contractid,
count(materialgroup) cm,
count(distinct materialgroup) cdm,
max(materialgroup) mm,
rtrim(
xmlagg(
xmlelement(e, materialgroup|| '|')).extract('//text()'),'|') materialgroup,
rtrim(
xmlagg(
xmlelement(e, commoditycode|| '|')).extract('//text()'),'|') commoditycode,amount
from (
with t1 as (
select 'C123' contractid, 'Travel' materialgroup, 200 commoditycode, 100 amount from dual union all
select 'C123', 'Travel', 201, 100 from dual union all
select 'C123', 'Travel', 203, 100 from dual union all
select 'C124','Stationery', 315, 500 from dual union all
select 'C126','Travel', 200, 600 from dual union all
select 'C126','Admin',413, 600 from dual )
select * from t1)
group by contractid,amount
) t;
CONTRACTID CM CDM MM MATERIALGROUP COMMODITYCODE AMOUNT MATERIALGROUP_EDIT MATERIALGROUP_EDIT2
C123 3 1 Travel Travel|Travel|Travel 200|203|201 100 Travel Travel
C124 1 1 Stationery Stationery 315 500 Stationery Stationery
C126 2 2 Travel Travel|Admin 200|413 600 Travel|Admin Travel|Admin
3 rows selected.
select contractid,
case when count(distinct materialgroup) = 1 and count(materialgroup) > 1 then max(materialgroup)
else
rtrim(
xmlagg(
xmlelement(e, materialgroup|| '|')).extract('//text()'),'|') end materialgroup,
rtrim(
xmlagg(
xmlelement(e, commoditycode|| '|')).extract('//text()'),'|') commoditycode,amount
from (
with t1 as (
select 'C123' contractid, 'Travel' materialgroup, 200 commoditycode, 100 amount from dual union all
select 'C123', 'Travel', 201, 100 from dual union all
select 'C123', 'Travel', 203, 100 from dual union all
select 'C124','Stationery', 315, 500 from dual union all
select 'C126','Travel', 200, 600 from dual union all
select 'C126','Admin',413, 600 from dual )
select * from t1)
group by contractid,amount;
CONTRACTID MATERIALGROUP COMMODITYCODE AMOUNT
C123 Travel 200|203|201 100
C124 Stationery 315 500
C126 Travel|Admin 200|413 600
3 rows selected.
with t1 as (
select 'C123' contractid, 'Travel' materialgroup, 200 commoditycode, 100 amount from dual union all
select 'C123', 'Travel', 201, 100 from dual union all
select 'C123', 'Travel', 203, 100 from dual union all
select 'C124','Stationery', 315, 500 from dual union all
select 'C126','Travel', 200, 600 from dual union all
select 'C126','Admin',413, 600 from dual ),
t2 as
select contractid, materialgroup
from t1
group by contractid, materialgroup
select t1.contractid,
t2.materialgroup,
rtrim(
xmlagg(
xmlelement(e, commoditycode|| '|')).extract('//text()'),'|') commoditycode,amount
from t1,
select contractid,
rtrim(
xmlagg(
xmlelement(e, materialgroup|| '|')).extract('//text()'),'|') materialgroup
from t2
group by contractid
) t2
where t1.contractid = t2.contractid
group by t1.contractid, t2.materialgroup, t1.amount;
CONTRACTID MATERIALGROUP COMMODITYCODE AMOUNT
C123 Travel 200|203|201 100
C124 Stationery 315 500
C126 Admin|Travel 200|413 600
3 rows selected.
Maybe you are looking for
-
How to remove cached images in html whe going from one page to another page
can anybody help how to remove cached images in html pages.i tried with response.setHeader("no-cache") but it is not working
-
Analog to Digital Conversion Via Firewire
I have an HVX-200 and need to do some Analog conversion from older VHS Tapes into FCP 6.0 on my Mac Pro for a current project. I assumed I could just set up the HVX as a non controllable device and begin capturing the input that was visible in the lo
-
Spry displaying in Firefox & Safari, but not in IE
Ok, so I was trying to replicate one of the demos: http://labs.adobe.com/technologies/spry/demos/rssreader/index.html Except that we're running on a LAMP platform which meant I had to rerwite the ColdFusion into PHP. I'm hoping the PHP isn't the issu
-
my new downloads are mpeg4 my old are mp3. Is there a way to make them all mp3 so I can transfer them?
-
HT4356 no printer shown on I pad, I phone 4s or I Pad
I have a new printer HP Officejet6600, all set up fine just cant print from my Iphone 4s Ipad or Ipod, It says it is compatable for air print, my other HP printer didn't work either but the Epsom one did, could it be the operating system on my comput