英文:
use one measure value in another measure as a filter in power BI
问题
Max_date = MAX('418k'[Crawl_date]).
The above "Max_date" I am using in another measure then is throwing an error message.
ex - sales/day = CALCULATE(SUM('418k'[Sales_count]), '418k'[Crawl_date] = [Max_date])
error message - a placeholder has been used in a true/false expression that is used as a table filter expression.
If am using it directly then there is no error
ex - sales/day = CALCULATE(SUM('418k'[Sales_count]), '418k'[Crawl_date] = MAX('418k'[Crawl_date]))
But I would like to use the [Max_date] ( variable ) in the filter instead of MAX('418k'[Crawl_date]).
英文:
I am finding a measure (Max_date) from a date column (Crawl_date). I would like to use the value of that measures in another measure as a filter.-- "
Max_date = MAX('418k'[Crawl_date]).
The above "Max_date" I am using in another measure then is throwing an error message.
ex - sales/day = CALCULATE(SUM('418k'[Sales_count]),'418k'[Crawl_date] = [Max_date])
error message - a placeholder has been used in a true/false expression that is used as a table filter expression.
If am using it directly then there is no error
ex - sales/day = CALCULATE(SUM('418k'[Sales_count]),'418k'[Crawl_date] = MAX('418k'[Crawl_date]))
But I would like to use the [Max_date] ( variable ) in the filter instead of MAX('418k'[Crawl_date]).
答案1
得分: 2
你已经在某种程度上回答了自己的问题 - 只需使用一个变量来存储您的度量值:
例如 - 销售/天 =
VAR _max = [Max_date]
RETURN
CALCULATE (
SUM( '418k'[Sales_count] ),
'418k'[Crawl_date] = _max
)
英文:
You have sort of answered your own question - just use a variable to store your measure value:
ex - sales/day =
VAR _max = [Max_date]
RETURN
CALCULATE (
SUM( '418k'[Sales_count] ),
'418k'[Crawl_date] = _max
)
答案2
得分: 1
你可以使用变量来实现这一点:
ex - sales/day =
VAR _max_date = [Max_date]
RETURN
CALCULATE ( SUM ( '418k'[Sales_count] ), '418k'[Crawl_date] = _max_date )
https://learn.microsoft.com/en-us/dax/best-practices/dax-variables
英文:
you can use variables for that:
ex - sales/day =
VAR _max_date = [Max_date]
RETURN
CALCULATE ( SUM ( '418k'[Sales_count] ), '418k'[Crawl_date] = _max_date )
https://learn.microsoft.com/en-us/dax/best-practices/dax-variables
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论