Powerbi 上一年度标准化金额

Powerbi 上一年度标准化金额,powerbi,dax,Powerbi,Dax,我有一个名为“normalizedata”的列,它有两个值“yes”和“no” 要求: Prev_YR_Trans = #getting the current & previous time period from Table "X" VAR prevSeason = CALCULATE(MAX('X'[Time Period]))-1 VAR maxSeason = CALCULATE(MAX('X'[Time Period])) #getting var

我有一个名为“normalizedata”的列,它有两个值“yes”和“no”

要求:

Prev_YR_Trans = 

#getting the current & previous time period from Table "X"
VAR prevSeason = CALCULATE(MAX('X'[Time Period]))-1
VAR maxSeason = CALCULATE(MAX('X'[Time Period]))

#getting variance b/w prev and current time periods
VAR maxSeason_footfall = CALCULATE(SUM('Y'[Park_Footfall]),'Y'[Time Period]=maxSeason)
VAR prevSeason_footfall = CALCULATE(SUM('Y'[Park_Footfall]),'Y'[Time Period]=prevSeason)
VAR footfall_variance = 1+((maxSeason_footfall-prevSeason_footfall)/prevSeason_footfall)

#trying to get the option that the user clicks on(?)
VAR bb = CALCULATE(('X'[Normalize data]))

#returns normalized numbers if user chooses "Yes" else returns actual numbers
RETURN 
IF(bb="Yes",
CALCULATE(SUM('X'[Receipt Count]),'X'[Time Period]= prevSeason)*footfall_variance,
CALCULATE(SUM('X'[Receipt Count]),'X'[Time Period]= prevSeason)
)
当用户单击“是”时,我希望我的度量(称为Prev_YR_Trans)做一件事,但如果用户单击“否”,我希望度量做另一件事

让我用一个例子来解释-我的度量值Prev_YR_Trans显示上一时间段的事务。假设当前时间段为“25”,那么它将显示时间段“24”的事务。现在,如果用户单击“是”,那么我希望上一年的交易“正常化”,即我希望它乘以两个时间段的方差b/w

我尝试过的:

Prev_YR_Trans = 

#getting the current & previous time period from Table "X"
VAR prevSeason = CALCULATE(MAX('X'[Time Period]))-1
VAR maxSeason = CALCULATE(MAX('X'[Time Period]))

#getting variance b/w prev and current time periods
VAR maxSeason_footfall = CALCULATE(SUM('Y'[Park_Footfall]),'Y'[Time Period]=maxSeason)
VAR prevSeason_footfall = CALCULATE(SUM('Y'[Park_Footfall]),'Y'[Time Period]=prevSeason)
VAR footfall_variance = 1+((maxSeason_footfall-prevSeason_footfall)/prevSeason_footfall)

#trying to get the option that the user clicks on(?)
VAR bb = CALCULATE(('X'[Normalize data]))

#returns normalized numbers if user chooses "Yes" else returns actual numbers
RETURN 
IF(bb="Yes",
CALCULATE(SUM('X'[Receipt Count]),'X'[Time Period]= prevSeason)*footfall_variance,
CALCULATE(SUM('X'[Receipt Count]),'X'[Time Period]= prevSeason)
)
在我上面的度量中,“
VAR bb=CALCULATE(('X'[Normalize data]))
给了我一个错误,因为它需要一些聚合,比如max、min、sum等

如何解析度量值以使其显示正确的数字?

编辑(解决)有关“规范化数据”列的更多信息:

Prev_YR_Trans = 

#getting the current & previous time period from Table "X"
VAR prevSeason = CALCULATE(MAX('X'[Time Period]))-1
VAR maxSeason = CALCULATE(MAX('X'[Time Period]))

#getting variance b/w prev and current time periods
VAR maxSeason_footfall = CALCULATE(SUM('Y'[Park_Footfall]),'Y'[Time Period]=maxSeason)
VAR prevSeason_footfall = CALCULATE(SUM('Y'[Park_Footfall]),'Y'[Time Period]=prevSeason)
VAR footfall_variance = 1+((maxSeason_footfall-prevSeason_footfall)/prevSeason_footfall)

#trying to get the option that the user clicks on(?)
VAR bb = CALCULATE(('X'[Normalize data]))

#returns normalized numbers if user chooses "Yes" else returns actual numbers
RETURN 
IF(bb="Yes",
CALCULATE(SUM('X'[Receipt Count]),'X'[Time Period]= prevSeason)*footfall_variance,
CALCULATE(SUM('X'[Receipt Count]),'X'[Time Period]= prevSeason)
)
我已经解决了“normalizedata”列,创建了一个名为“normalizeslicer”的新表,其中包含yes/no值。这是你的电话号码

另外,如果你也能帮我完成我的“规范化数据”专栏,那就太好了

因此,对于“normalizedata”列,我只希望它显示两个选项“Yes”和“No”,但我意识到我需要将其创建为一个列,以使切片器功能正常工作

因此,对于我的公式,如果“时间段”小于或等于上一个时间段,我想显示“是”,否则显示“否”

我试着做到以下几点:

Normalize data = IF('X'[Time Period]<=(CALCULATE(MAX('X'[Time Period]))-1),"Yes","No")
标准化数据=IF('X'[时间段]代替

VAR bb = CALCULATE(('X'[Normalize data]))
使用以下命令:

var bb = SELECTEDVALUE('X'[Normalize data])