Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
KaZeK
Frequent Visitor

DAX table creation depended by variables

Dear Community, 

 

I am Power BI beginner, but I'm trying to use already existing knowledge on this forum. Today, I created account because I need to ask you for support for my issue which I faced because I have no idea how to make it...

 

I have variables:

 

VAR SR30MIN = -100
VAR SR30MAX = 800
VAR PeriodQuantity = ((SR30MAX + ABS(SR30MIN))/100)*5
VAR PeriodRange = SR30MAX + ABS(SR30MIN)
VAR PeriodStep = PeriodRange / PeriodQuantity
VAR LoopTable = GENERATESERIES(SR30MIN, SR30MAX, PeriodStep)
VAR MainTable = ADDCOLUMNS(LoopTable, PeriodStep?, ?)
Return
Main Table
 
How to find parameters for ADDCOLUMN() function to get table like:
 
Value               LoopName          
SR30MIN         Period(1)
...                      Period(n+1)
...                      ...
...                      ...
SR30MAX        Period(PeriodQuantity)

Thanks in advance for any suggestions!
 
Regards
Kazek
2 REPLIES 2
amitchandak
Super User
Super User

@KaZeK , GENERATESERIES will give you a column Value , which you can use in Addcolumns to ahve some calculation

 

Example we are using date from the calendar to calculate other columns

 

Calendar = Addcolumns(calendar(date(2020,01,01), date(2021,12,31) ), "Month no" , month([date])
, "Year", year([date])
, "Month Year", format([date],"mmm-yyyy")
, "Month year sort", year([date])*100 + month([date])
, "Qtr Year", format([date],"yyyy-\QQ")
, "Qtr", quarter([date])
, "Month",FORMAT([Date],"mmmm")
, "Month sort", month([DAte])
, "Is Today" ,if([Date]=TODAY(),"Today",[Date]&"")
, "Month Type", Switch( True(),
eomonth([Date],0) = eomonth(Today(),-1),"Last Month" ,
eomonth([Date],0)= eomonth(Today(),0),"This Month" ,
Format([Date],"MMM-YYYY") )
,"Year Type" , Switch( True(),
year([Date])= year(Today()),"This Year" ,
year([Date])= year(Today())-1,"Last Year" ,
Format([Date],"YYYY")
)
)

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hello Amitchandak,

 

Based on your responce I see that this is not exactly what I need. I would like to create new table based on the GENERATESERIES() function...

I tried to do something like below, but it doesnt work, probably there are some mistakes, can you have a look please?

 

VAR RangeSeries = GENERATESERIES(MINSR30, MAXSR30, PeriodStep),
VAR PeriodNo = GENERATESERIES(1, PeriodQuantity, 1)
MyTable = GENERATE(
      SR30RangeLOW = [RangeSeries],
      SR30RangeHI = [RangeSeries] + PeriodStep,
      SR30Name = "Period" && PeriodNo
)
 

 

I know that function Generate() can have only 2 arguments, but how can I create table with 3 columns: 
SR30RangeLOW, SR30RangeHI and SR30Name which will take values from GENERATESERIES() function.
Both GENERATESERIES() functions generated the same amount of raws.
 
Regards
Kazek

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors