我正在尝试创建一个只有当月数据的线图。我的日期字段称为购买的
。我还将其用于仪表板上的“日期范围选择器”小部件。我的尺寸是购买的
,我的度量是 publicvolume
。我的数据看起来像这样:
我如何设置一个条件以仅使用当前/最新月份的台表?
我尝试使用这样的变量:
curressMonth = max(puferataedate)
,我将行图中的表达式设置为:
尺寸: if(Curstralth,购买)
测量:如果(CurressMonth,pupluevolume)
,
但是在这里,我的价值观根据日期Ranger Picker的选定日期不断变化。我如何仅设置最新月份的线条图(因此,尺寸将在最近一个月的每一天,在这种情况下是2022年1月)?有什么方法可以设置计算条件?
I'm trying to create a line chart with the data for only the current month. My date field is called PurchaseDate
. I use this also for the 'Date Range Picker' widget in my dashboard. My dimension is PurchaseDate
and my measure is PurchaseVolume
. My data looks like this:

How can I set a condition to use only the current/latest month for my line chart?
I tried using a variable like this:
CurrentMonth = Max(PurchaseDate)
And I set the expression in my line chart to:
Dimension: if(CurrentMonth, PurchaseDate)
Measure: if(CurrentMonth, PurchaseVolume)
But here, my values keep changing according to the selected date on the Date Ranger Picker. How can I set the line chart for only the latest month (so the dimension will have each day of the latest month, which in this case will be Jan 2022) independent of the Date Range Picker? Is there a way I can set the calculation condition?
发布评论
评论(1)
您可以在表达式中使用集合分析来过滤
购买的
(s), montrystart 和 monthend> monthend> monthend 最大月份:sum({< (= montrystart(max({1} puferatedate))))< = $(= monthend(max({1} puferaseatedate)))“}>} puplyVolume)
有趣的路径是设置分析:
< = {“
月末(max({1}购买)
将返回最大可能日期 code> {1}monthstart
和monthend
函数是忽略所有可能的选择
结果表是:
在两个日期之间具有
的月末字段
替代方案是在表中(或日历表中的另一个字段,如果存在)。该字段将与每个日期关联,并代表日期的月份。例如:
在这种情况下,表达式将是:
sum({&lt; pupperaseedate =,puchasemonth = {“ $(= max({1} puplasemonth))”}&gt;} puplyVolume)
(
puferacateate =
最初是为了忽略购买的所有选择
字段),两个表的结果将相同:
//i.sstatic.net/rs3eg.png“ rel =“ nofollow noreferrer”>
You can use set analysis in your expression to filter
PurchaseDate
(s) which are between the MonthStart and MonthEnd of the max possible month:Sum({<PurchaseDate={">=$(=Monthstart(max({1}PurchaseDate)))<=$(=monthend(max({1}PurchaseDate)))"} >} PurchaseVolume)
The interesting path is the set analysis:
PurchaseDate={">=$(=MonthStart(max({1}PurchaseDate)))<=$(=MonthEnd(max({1}PurchaseDate)))"}
Monthstart(max({1}PurchaseDate)
will return the start date of the max possible dateMonthEnd(max({1}PurchaseDate)
will return the end date of the max possible date{1}
beforeMonthStart
andMonthEnd
functions is toignore all possible selections when calculating
The result table is:
Having month end field
Alternative of
between two dates
is to have another field in the table (or in the calendar table, if exists). This field will be associated with each date and will represent the month of the date. For example:In this case the expression will be:
Sum({<PurchaseDate=, PurchaseMonth={"$(=max({1}PurchaseMonth))"}>} PurchaseVolume)
(
PurchaseDate=
is to initially to ignore all selections inPurchaseDate
field)And the result of both tables will be the same:
For the record, my script is: