Yes, dahlias and elderberry shrubs can be planted in the same garden, but they should not occupy the same planting hole or be treated as interchangeable companions: elderberries are long-lived, large woody shrubs that want consistently moist soil and at least two compatible cultivars for cross-pollination, while dahlias are tender perennials usually grown as annuals or lifted for winter, need excellent drainage, and bloom best in full sun without root competition. The pairing works as a landscape arrangement—elderberry as a background or hedgerow shrub, dahlias as seasonal color in front—rather than as close interplanting. The query does not specify climate, soil type, or whether "planted" means adjacent beds or the same spot, so the answer below separates what is broadly true from what depends on local conditions.

What each plant actually needs

Elderberry (Sambucus species, chiefly S. canadensis in North America and S. nigra in Europe). Elderberries are vigorous deciduous shrubs or small trees, commonly reaching 6–12 feet tall and wide depending on species and cultivar. They produce new canes from the base and fruit on second-year wood, so pruning renewal matters more than tip pruning. They prefer moist, fertile, slightly acidic to neutral soil and tolerate wetter ground than most ornamentals; in the wild they often colonize stream margins and hedgerows. Most fruiting cultivars benefit from a second genetically distinct cultivar nearby for good fruit set, because they are not reliably self-fruitful. The shrub's root system is substantial and spreading once established.

Dahlias (Dahlia hybrids). Dahlias are tuberous-rooted perennials from Mexico and Central America, grown as tender perennials in mild climates (roughly USDA zones 8–10, depending on cultivar and microclimate) and as annuals or lifted-and-stored plants elsewhere. They need full sun, warm soil, and, critically, well-drained soil; waterlogged tubers rot. They grow 1–6 feet tall depending on type (bedding, border, pompon, dinner-plate), and they flower from midsummer into frost. They are heavy feeders and thirsty during bloom but intolerant of standing water.

The core conflict is drainage versus moisture. Elderberry tolerates and even likes soil that stays damp; dahlia tubers are among the plants most reliably killed by wet, poorly drained ground, especially during dormancy. That single difference determines where each should go.

Why "planted together" is ambiguous

Three readings of the question give three different answers:

1: Same garden or bed, different positions. Entirely workable. Site elderberry where its size and moisture preference fit—often the wetter end of a border or a hedgerow—and place dahlias in a sunnier, better-drained section. 2: Same planting hole or immediate root zone. Not advisable. The elderberry will outcompete the dahlia for water and nutrients within a season or two, its shade will reduce dahlia flowering, and digging up dahlia tubers for winter storage becomes difficult without disturbing elderberry roots. 3: As a designed companion planting with claimed mutual benefit. No reliable horticultural evidence supports pest-repelling or growth-enhancing synergy between these two. They can coexist; they do not assist each other.

Practical arrangement if you want both

Spacing. Keep dahlias outside the elderberry's mature drip line, typically at least 4–6 feet from the trunk of a mature shrub, more if the elderberry is vigorous. Newly planted elderberries are small, but plan for the mature spread rather than the nursery-pot size. Sun. Dahlias want 6+ hours of direct sun. Elderberries fruit best in full sun but tolerate partial shade. In a tight garden, give dahlias the sunniest spot and let elderberry take afternoon shade. Soil and water. Amend the dahlia area for drainage (compost plus grit or coarse sand in heavy clay; raised beds where drainage is poor). Do not "improve" the elderberry site by making it dry—elderberry's moisture tolerance is an asset, so use it where dahlias would fail. Competition. Elderberry's roots and canopy will suppress nearby plants over time. Dahlias planted too close will be stunted and flower less. Use the elderberry as a backdrop, not a neighbor in the same square yard. Seasonal timing. Plant elderberry in dormant season (late fall to early spring, soil workable). Plant dahlias after the last frost when soil has warmed to roughly 60°F, or start tubers indoors. These calendars rarely coincide, which is another reason to treat them as separate plantings. Winter handling. In cold climates, dahlia tubers are lifted after frost and stored; elderberry stays in the ground. Mark dahlia clumps clearly so spring digging doesn't damage elderberry roots.

Where the answer stops applying

Very wet sites. If the ground stays saturated, elderberry may thrive but dahlias will likely rot. Choose one, or install raised beds for the dahlias. Very dry, sandy sites. Elderberry will need irrigation to establish and crop well; dahlias also need water but tolerate sharper drainage. Both can work with irrigation, but elderberry is the more demanding of consistent moisture. Small containers or patios. Elderberry is a poor long-term container plant because of its size; dahlias do well in large containers. The pairing really belongs in open ground. Shade gardens. Neither is a shade plant. Dahlias in particular will be leggy and sparse in less than about six hours of sun. Poisoning concerns. Elderberries must be cooked before eating; raw berries and other plant parts contain cyanogenic glycosides and can cause illness. This is a handling caution, not a reason they can't be grown near dahlias.

Common confusions worth separating

"Elderberry" vs. "elderflower." Both come from the same shrub; the flower is used in syrups and the cooked fruit in jams and pies. The ornamental cut-leaf and dark-foliage elders (some Sambucus nigra cultivars) are grown for foliage color and may fruit less abundantly—relevant if you want a hedge that also feeds birds or a harvest.

Dahlias as perennials vs. annuals. In mild-winter regions, dahlias can be left in the ground with mulch; elsewhere they are effectively annuals unless lifted. Calling them "perennials" without qualification misleads gardeners in cold climates.

Companion planting claims. "Companion planting" is often used loosely for any two plants grown near each other. Here the accurate statement is coexistence with spatial separation, not beneficial interaction.

Toxic-lookalike worry. Elderberry's uncooked fruit and foliage are mildly toxic, and some wild Sambucus relatives (e.g., red-berried elders) are not the culinary species. If harvesting, confirm species and cook thoroughly.

Bottom line

Plant them in the same garden if you give each the site it needs: elderberry in a moist, roomy spot where its mature size is acceptable, dahlias in full sun with sharp drainage and out of the shrub's root zone. Don't plant them in the same hole or expect them to help each other, and don't put dahlias where the ground stays wet. The remaining unknowns—your climate zone, soil drainage, and available space—determine the specific layout, and those are the details to check locally before digging.