Reputation: 11
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
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