Get certified for free when you join Fabric Data Days 2026 and dive into Fabric, Power BI, SQL, AI, and other essential data skills.
Join nowJuly 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more
Hi,
I am wondering if it is possible to create a dynamic table with multiple columns.
I am looking to generate a table for historical data view ranges, a mix of static values and previous years, combined with a calculated sort order.
For Example:
I can create the first column with:
Historical Data = UNION(DATATABLE("HistoricalData",STRING,{{"1M"},{"3M"},{"6M"},{"9M"},{"12M"}}),distinct(Dates[Year]))
And I typically create the second field with:
Solved! Go to Solution.
Hi,
I think I got this code to work:
Historical data =
VAR _minYear =
MIN ( vDate[Year] )
RETURN
UNION (
DATATABLE (
"HistoricalData"; STRING;
"Sort"; INTEGER;
{
{ "1M"; 1 };
{ "3M"; 2 };
{ "6M"; 3 };
{ "9M"; 4 };
{ "12M"; 5 }
}
);
ADDCOLUMNS ( DISTINCT ( vDate[Year] ); "Sort"; vDate[Year] - _minYear + 6 )
)Cheers,
S
Hi,
I think I got this code to work:
Historical data =
VAR _minYear =
MIN ( vDate[Year] )
RETURN
UNION (
DATATABLE (
"HistoricalData"; STRING;
"Sort"; INTEGER;
{
{ "1M"; 1 };
{ "3M"; 2 };
{ "6M"; 3 };
{ "9M"; 4 };
{ "12M"; 5 }
}
);
ADDCOLUMNS ( DISTINCT ( vDate[Year] ); "Sort"; vDate[Year] - _minYear + 6 )
)Cheers,
S
Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.
Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.
| User | Count |
|---|---|
| 2 | |
| 2 | |
| 2 | |
| 1 | |
| 1 |
| User | Count |
|---|---|
| 4 | |
| 4 | |
| 3 | |
| 3 | |
| 3 |