Showing results for 
Search instead for 
Did you mean: 
New Member

Dynamic Columns

I'm wanting to add about 20 columns to a table (Column1 - Column20) all with the same formula as displayed below, any help will be appreciated. At the moment I'm doing this one line at a time 🤔




Table.AddColumn(#"Expanded Date Dimension1", "Column1", each if [MonthStart]<=0 and [MonthEnd]>=0 then " " else "")




Thanks for you help

Super User
Super User

= List.Accumulate({1..20}, #"Expanded Date Dimension1", (s,c) => Table.AddColumn(s, "Column"&Text.From(c), each if [MonthStart]<=0 and [MonthEnd]>=0 then "x" else "y"))


Thanks to the great efforts by MS engineers to simplify syntax of DAX! Most beginners are SUCCESSFULLY MISLED to think that they could easily master DAX; but it turns out that the intricacy of the most frequently used RANKX() is beyond their comprehension!

DAX is simple, but NOT EASY!

Super User
Super User


In advanced editor you can paste this code 20 times with different step names  and column names!


Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
MY Blog || My YouTube Channel || Connect with me on Linkedin || My Latest Data Story - Ageing Analysis

Proud to be a Super User!

Helpful resources

September Update

Check it Out!

Click here to learn more about the September 2022 updates!

Power BI Dev Camp Session 26

Check it Out!

Mark your calendars and join us on Thursday, September 29 at 11a PDT for a great session with Ted Pattison!

Top Kudoed Authors