Jeevan A Y
Jeevan A Y

Reputation: 11

DAX formula to create a date table

In one of the interview today, interviewer has sent the below SQL query and asked me to write a DAX formula in Power BI.

create table dim_date (datekey int)
declare @x int = 0
while @x <=365
begin
insert into dim_date values (dateadd(getdate(),@x))
set @x=@x+1
end

Please help me to write DAX for this SQL query.

Upvotes: 0

Views: 175

Answers (1)

Andrey Nikolov
Andrey Nikolov

Reputation: 13440

You can use CALENDAR and TODAY DAX functions to create a calculated table like this:

dim_date = CALENDAR(TODAY(), TODAY() + 365)

Upvotes: 1

Related Questions