[英]Escape Level of Detail expression in Tableau
I'm trying to build a calculation that takes their values from a Parameter.我正在尝试构建一个从参数中获取它们的值的计算。 The paramater is feeded from a string dimension.
参数是从字符串维度提供的。
Using SuperStore as an example, I've created a Parameter called Country Par
containing all the Country/Region
values.以 SuperStore 为例,我创建了一个名为
Country Par
的参数,其中包含所有Country/Region
值。
For example, let's assume I have as a page filter Country/Region
= France
and the value for the Country Par
= United Kingdom
.例如,假设我有一个页面过滤器
Country/Region
= France
和Country Par
= United Kingdom
的值。 Also, Month(Order Date)
for Columns and Measure Values
for Rows.此外,列的
Month(Order Date)
和行的Measure Values
。
The measure values selected will be:选择的测量值将是:
SUM(Sales)
SUM(Comparable Country Sales)
What I'm trying to achieve with the calculation is to retrive the values selected from the Parameter - in this case United Kingdom - ignoring whatever is selected as page filter.我试图通过计算实现的是检索从参数中选择的值 - 在本例中为英国 - 忽略选择为页面过滤器的任何内容。 (France in the example).
(以法国为例)。
And the same time I want to filter the Sales for United Kingdom ending the same month as Finland.同时我想过滤与芬兰同月结束的英国销售额。
But due to the FIXED context, seems like LOD is not able to pickup the last month of Finland - Oct 2019.但由于FIXED上下文,LOD 似乎无法获取芬兰的最后一个月 - 2019 年 10 月。
Comparable Country Sales可比国家销售额
{fixed MONTH([Order Date]):
sum(
if [Country/Region]=[Country Par]
and month([Order Date]) <= {max(if [Country/Region]="Finland" then month([Order Date]) end)}
then [Sales]
else null
END)}
This is only a representation of what I want to achieve in my original datasets, for obvious reasons I can't share the data.这只是我想在我的原始数据集中实现的一个表示,原因很明显,我无法共享数据。
A few suggestions here-这里有一些建议——
I have proceeded like this..我是这样进行的。。
( Note: In superstore data, I have played around on State field instead on Country as in latest version only US data is available) (注意:在超市数据中,我在 State 字段上玩过,而不是在 Country 上玩过,因为在最新版本中只有美国数据可用)
desired calculated field
with calculation as desired calculated field
,计算为
{fixed DATETRUNC('month', [Order Date]):
sum(
if [State]= [Par1]
and ([Order Date]) <= {max(if [State] = [Par2] then ([Order Date]) end)}
then [Sales]
else null
END)}
See this works in my case看看这在我的情况下有效
Good Luck祝你好运
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.