Skip to main content
Announcements
Global Transformation Awards! Applications are now open. Submit Entry
cancel
Showing results for 
Search instead for 
Did you mean: 
zturaiki
Contributor III
Contributor III

grouping and autonumber

Need help in this ..

I have One table , contain these Data :

SectionSub-SectionDrug Class
Anaesthetics, Muscle Relaxants and PremedsPremedicationBenzodiazepines
Anaesthetics, Muscle Relaxants and PremedsMiscellaneousOpioid analgesics
Central Nervous SystemEpilepsyBarbiturates
Central Nervous SystemEpilepsyBarbiturates
Central Nervous SystemEpilepsyBarbiturates
Anaesthetics, Muscle Relaxants and PremedsPremedicationBenzodiazepines
Anaesthetics, Muscle Relaxants and PremedsMiscellaneousOpioid analgesics
Central Nervous SystemAnxietyBenzodiazepines
Anaesthetics, Muscle Relaxants and PremedsMiscellaneousOpioid analgesics

we have Section and under the section is sub section , and under sub sectio is Drug Class

i want to change the view to :

section codeSectionsub section codeSub-Sectiondrug classDrug ClassItem code
1Anaesthetics, Muscle Relaxants and Premeds1Premedication1Benzodiazepines1.1.1
1Anaesthetics, Muscle Relaxants and Premeds2Miscellaneous1Opioid analgesics1.2.1
2Central Nervous System1Epilepsy1Barbiturates2.1.1
2Central Nervous System1Epilepsy1Barbiturates2.1.1
2Central Nervous System1Epilepsy1Barbiturates2.1.1
1Anaesthetics, Muscle Relaxants and Premeds1Premedication2Benzodiazepines1.1.2
1Anaesthetics, Muscle Relaxants and Premeds2Miscellaneous2Opioid analgesics1.2.2
2Central Nervous System2Anxiety1Benzodiazepines2.2.1
1Anaesthetics, Muscle Relaxants and Premeds2Miscellaneous3Opioid analgesics1.2.3
1 Solution

Accepted Solutions
hic
Former Employee
Former Employee

If you want the autonumbering to restart from 1 within each group, then try

Load *,

          [section code] &'.'& [sub section code]  &'.'& [Drug Class code] as [Item code]

          ;

Load

          Section,

          Autonumber(Section, 'Section') as [section code],

          [Sub-Section],

          Autonumber([Sub-Section], 'Sub-Section' & Section) as [sub section code],

          [Drug Class],

          Autonumber([Drug Class],'Drug Class' & [Sub-Section]) as [Drug Class code]

          From ...

HIC

View solution in original post

6 Replies
hic
Former Employee
Former Employee

Load *,

          [section code] &'.'& [sub section code]  &'.'& [Drug Class code] as Item code

          ;

Load

          Section,

          Autonumber(Section, 'Section') as [section code],

          [Sub-Section],

          Autonumber([Sub-Section],'Sub-Section') as [sub section code],

          [Drug Class],

          Autonumber([Drug Class],'Drug Class') as [Drug Class code]

          From ...

HIC

swuehl
MVP
MVP

Zain,

it seems that the same combination of values is assigned a different code, e.g.

1Anaesthetics, Muscle Relaxants and Premeds1Premedication1Benzodiazepines1.1.1
1Anaesthetics, Muscle Relaxants and Premeds2Miscellaneous1Opioid analgesics1.2.1
1Anaesthetics, Muscle Relaxants and Premeds1Premedication2Benzodiazepines1.1.2
1Anaesthetics, Muscle Relaxants and Premeds2Miscellaneous2Opioid analgesics1.2.2

I believe the suggested autonumber will not consider these.

While other combinations are assigned same code (Central Nervous System | Epilepsy | Barbiturates).

What's the logic behind, when do you assign same and when do you assign different codes?

zturaiki
Contributor III
Contributor III
Author

  I work with your solution ,, but it not give me the same result as I want ,,,

zturaiki
Contributor III
Contributor III
Author

  I will explain it to you ,,,

In the section we have ,,, Anaesthetics, Muscle Relaxants and Premeds ,,,, I want to auto number it

Under this section is two sub sections ,,,, I want to auto number start from 1

1     Premedication     

2 Miscellaneous

Under each sub sections is drug class ,,, I want to auto number it

Sub section ,,,Premedication

Under it is drug class ,,,

1     Benzodiazepines     

2.      Opioid analgesics     

other sub section is ,,, Miscellaneous

Under it ,, the following drag class

1 Benzodiazepines     

2  Opioid analgesics     

The goal is to auto number and start the auto number from 1 for each group and sub group

hic
Former Employee
Former Employee

If you want the autonumbering to restart from 1 within each group, then try

Load *,

          [section code] &'.'& [sub section code]  &'.'& [Drug Class code] as [Item code]

          ;

Load

          Section,

          Autonumber(Section, 'Section') as [section code],

          [Sub-Section],

          Autonumber([Sub-Section], 'Sub-Section' & Section) as [sub section code],

          [Drug Class],

          Autonumber([Drug Class],'Drug Class' & [Sub-Section]) as [Drug Class code]

          From ...

HIC

zturaiki
Contributor III
Contributor III
Author

Thanks ,,, it works fine