Datedim 函数不返回昨天的日期 webi
Datedim function not returning yesterdays date webi
我的 Datedim 函数没有在 webi 中返回昨天的日期,关于如何显示 13/04/2022 的任何想法,即使它有空值?
谢谢
如果日期数据中存在空白,最简单的填充方法是使用 TimeDim() 函数创建一个变量。但是,这对您不起作用,因为您没有真正的差距,因为您错过的日期在最后。
您需要一个包含您想要显示的所有日期的数据源,无论您是否有这些日期的数据,然后在您的日期维度上合并。我回答了一个与此非常相似的问题here。我正在从下面复制我的答案...
The TimeDim() function will fill in the empty periods in your time
data. The problem with that though is if it is the end of your date
range that is missing data those dates will not show up. Let me show
you what I mean. Here is my sample data from 12/01/2021 through
12/26/2021 (note missing dates) in the table on the left. The table on
the right is the my Var Data Date TimeDim variable defined as…
=TimeDim([Data Date]; DayPeriod)
So we have our missing dates in the middle, but not at the end
(12/25/2021 and 12/26/2021). To get those dates you need a query to
return all the dates in your specified range. If you have a universe
based on a
calendar
you could use that. Free-hand SQL based on a calendar table would
suffice as well.
If you have neither of those we can still get it to work using
free-hand SQL with a CTE. This is SQL Server syntax. You will have to
modify this SQL to work for whatever database platform you have if it
isn’t SQL Server.
Here is the SQL…
;with dates ([Date]) as (
Select convert(date,‘2021-12-01’) as [Date] – Put the start date here
union all
Select dateadd(day, 1, [Date])
from dates
where [Date] < ‘2021-12-26’ – Put the end date here
)
select [Date]
from dates
option (maxrecursion 32767) – Don’t forget to use the maxrecursion option!
Source: Generate a Date Table via Common Table Expression (CTE) |
Data and Analytics with Dustin
Ryan
Here is a
demo.
Now that you have a query returning all of the dates in your range
you can merge the date from that query to your Data Date.
You can then put the date object with all of dates or the Merged Date
in table with any measures from your pre-existing query and there you
have it.
If you need to add dimensions from you pre-existing query I think you
will need to create variables for them with Qualification set to
“Detail” and the Associated dimension set to “Merged Date” (or
whatever you called it). And if you do that I believe you will also
need to check “Avoid duplicate row aggregation” check box within the
Format Table properties.
Let us know how it goes.
希望这会让您走上正轨。
我的 Datedim 函数没有在 webi 中返回昨天的日期,关于如何显示 13/04/2022 的任何想法,即使它有空值?
谢谢
如果日期数据中存在空白,最简单的填充方法是使用 TimeDim() 函数创建一个变量。但是,这对您不起作用,因为您没有真正的差距,因为您错过的日期在最后。
您需要一个包含您想要显示的所有日期的数据源,无论您是否有这些日期的数据,然后在您的日期维度上合并。我回答了一个与此非常相似的问题here。我正在从下面复制我的答案...
The TimeDim() function will fill in the empty periods in your time data. The problem with that though is if it is the end of your date range that is missing data those dates will not show up. Let me show you what I mean. Here is my sample data from 12/01/2021 through 12/26/2021 (note missing dates) in the table on the left. The table on the right is the my Var Data Date TimeDim variable defined as…
=TimeDim([Data Date]; DayPeriod)
So we have our missing dates in the middle, but not at the end (12/25/2021 and 12/26/2021). To get those dates you need a query to return all the dates in your specified range. If you have a universe based on a calendar you could use that. Free-hand SQL based on a calendar table would suffice as well.
If you have neither of those we can still get it to work using free-hand SQL with a CTE. This is SQL Server syntax. You will have to modify this SQL to work for whatever database platform you have if it isn’t SQL Server.
Here is the SQL…
;with dates ([Date]) as ( Select convert(date,‘2021-12-01’) as [Date] – Put the start date here union all Select dateadd(day, 1, [Date]) from dates where [Date] < ‘2021-12-26’ – Put the end date here ) select [Date] from dates option (maxrecursion 32767) – Don’t forget to use the maxrecursion option!
Source: Generate a Date Table via Common Table Expression (CTE) | Data and Analytics with Dustin Ryan
Here is a demo.
Now that you have a query returning all of the dates in your range you can merge the date from that query to your Data Date.
You can then put the date object with all of dates or the Merged Date in table with any measures from your pre-existing query and there you have it.
If you need to add dimensions from you pre-existing query I think you will need to create variables for them with Qualification set to “Detail” and the Associated dimension set to “Merged Date” (or whatever you called it). And if you do that I believe you will also need to check “Avoid duplicate row aggregation” check box within the Format Table properties.
Let us know how it goes.
希望这会让您走上正轨。