I have 1 Fact and 2 Dim and how can I create measure on condition
我有1个事实和2个维度,以及如何在条件下创建度量值
- DIM_DATE.U_DATE > Todaydate ==> 0
- DIM_TRAN.EXPIRY_DATE <= Todaydate ==> FACT_TRAN.Value
3.(else) DIM_DATE.U_DATE <= Todaydate && DIM_TRAN.Expiry_date > Todaydate
== > Datediff(DIM_DATE.U_DATE,DIM_TRAN.EXPIRY_DATE) * FACT_TRAN.Value/Datediff(DIM_DATE.U_DATE,DIM_TRAN.EXPIRY_DATE)
enter image description here
在此处输入图像描述
file to download .pbix ==> https://easyupload.io/rr3b0w
要下载的文件.ppix==>https://easyupload.io/rr3b0w
I try to use switch
Like this : Test M = SWITCH(TRUE(),
SELECTEDVALUE(DIM_DATE[U_DATE]) > TODAY(),0,1)
but value is multiple.
我试着这样使用开关:测试M=switch(TRUE(),SELECTEDVALUE(DIM_DATE[U_DATE])>TODAY(),0,1),但值是倍数。
enter image description here
在此处输入图像描述
更多回答
优秀答案推荐
Hi i have used IF dax function and selectedvalue dax function to buld the dax query. Logic is a bit unclear to me, but I have created the logic as you intended.
嗨,我使用了IF dax函数和selectedvalue dax函数来构建dax查询。逻辑对我来说有点不清楚,但我已经按照你的意图创建了逻辑。
_calmeasure =
VAR todaydate =
TODAY ()
VAR udate =
SELECTEDVALUE ( DIM_DATE[U_DATE] )
VAR expiry =
SELECTEDVALUE ( DIM_TRAN[EXPIRY_DATE] )
VAR cond =
IF (
udate > todaydate,
0,
IF (
expiry <= todaydate,
CALCULATE ( MAX ( FACT_TRAN[Value] ) ),
IF (
udate <= todaydate
&& expiry > todaydate,
DATEDIFF ( udate, expiry, DAY ) * SELECTEDVALUE ( FACT_TRAN[Value] )
/ DATEDIFF ( udate, expiry, DAY ),
0
)
)
)
RETURN
cond
更多回答
Thank you very much it help me to solve it
非常感谢它帮我解决了这个问题
Please upvote and accept my answer
请投赞成票并接受我的回答
我是一名优秀的程序员,十分优秀!