# Is it possible to create a set from a parameter?

**URL:** <https://discuss.ampl.com/t/is-it-possible-to-create-a-set-from-a-parameter/2280>\
**Category:** Support\
**Created:** [July 16, 2026, 12:06pm UTC](https://discuss.ampl.com/t/is-it-possible-to-create-a-set-from-a-parameter/2280 "2026-07-16T12:06:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Lothar\_Lower](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/lothar_lower/32/855_2.png) [@Lothar\_Lower](https://discuss.ampl.com/u/Lothar_Lower)\
**Post date:** [July 16, 2026, 12:06pm UTC](https://discuss.ampl.com/t/is-it-possible-to-create-a-set-from-a-parameter/2280/1 "2026-07-16T12:06:15Z")

</div>

I am reading parameter from an excel-file using amplxl.dll. Partly, the parameter data (columns in excel) contain empty data.

set MPC\_BRA\_ID default {};  
param bra\_type{MPC\_BRA\_ID} symbolic default ‘’;  
param bra\_tap\_pos{MPC\_BRA\_ID}; # no default here so far  
table tmp\_table IN “amplxl” (filename\_GRID) “mpc\_bra”: MPC\_BRA\_ID ← [mpc\_bra\_id], bra\_type, bra\_tap\_pos;  
read table tmp\_table;

As a result, let’s assume five branches, MPC\_BRA\_ID is a set containing five values. Also bra\_type contains five values since every branch has a type information like “line” or “transformer”. Having a look at bra\_tap\_position, some indices are missing because a value is only defined for a few transformer within the excel file. A lot of cells are simply empty.

e.g.  
display bra\_tap\_pos;  
bra\_tap\_pos [\*] =  
3 0  
5 2  
;

I want to create a new set dealing with the branches, which have a tap-position information.

The result shall be: new\_set = {3, 5};

Unfortunatelly, “0” is a valid information too. Thus, replacing the empty cell by “0” would mean that the transformer has tap position data.  
Evaluating the command

set new\_set = {i in MPC\_BRA\_ID: bra\_tap\_pos[i]};

contains only the indices which are not “0”.

Is there any possibility to create such a set, without using a default value outside a realistic range (param bra\_tap\_pos{MPC\_BRA\_ID} default -9999)?

Best regards,  
Lothar

---

<div class="post-metadata">

**Author:** ![4er](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/4er/32/530_2.png) [@4er](https://discuss.ampl.com/u/4er)\
**Post date:** [July 17, 2026, 7:20pm UTC](https://discuss.ampl.com/t/is-it-possible-to-create-a-set-from-a-parameter/2280/2 "2026-07-17T19:20:46Z")

</div>

There’s no easy way to define the set of “all bra\_tap\_pos[i] that have received a value so far.” Using `default -9999` is a clean approach, however.

[test.txt](https://discuss.ampl.com/uploads/short-url/1L4VGWiokSDI323qRPpIFApGyF.txt) (446 Bytes)  
[test.xlsx](https://discuss.ampl.com/uploads/short-url/hTyVTdhaikCnC3d7KU8ODdCtOei.xlsx) (8.3 KB)

---

<div class="post-metadata">

**Author:** ![marcos](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/marcos/32/154_2.png) [@marcos](https://discuss.ampl.com/u/marcos)\
**Post date:** [July 17, 2026, 10:41pm UTC](https://discuss.ampl.com/t/is-it-possible-to-create-a-set-from-a-parameter/2280/3 "2026-07-17T22:41:31Z")

</div>

Hi @Lothar_Lower ,

Just a remark, it could be more convenient to use `amplpy` to interact with tables or spreadsheets in python rather than read/update them in `ampl`. Data manipulation is usually easier in python

---

<div class="post-metadata">

**Author:** ![Lothar\_Lower](https://sea1.discourse-cdn.com/flex019/user_avatar/discuss.ampl.com/lothar_lower/32/855_2.png) [@Lothar\_Lower](https://discuss.ampl.com/u/Lothar_Lower)\
**Post date:** [July 23, 2026, 9:50am UTC](https://discuss.ampl.com/t/is-it-possible-to-create-a-set-from-a-parameter/2280/4 "2026-07-23T09:50:41Z")

</div>

Hi Robert & Marcos,  
Thank’s for the reply. So I will read the data using a default value of -9999 and create the set based on another set excluding all members which have a bra\_tap\_pos of this value.  
Best regards,  
Lothar
