过滤器中的最近日期 [英] Filter Recent date in filter
问题描述
我希望 Power BI 中的切片器选择要自动选择的选择的最近日期.
下面是下拉示例:
这是计算列的公式(在过滤器中使用):
Default_Date =VAR 今天日期 =今天()VAR 昨天日期 =今天() - 1VAR 报告日期 =开关(真(),'日历'[日期] = TodaysDate, "今天",'日历'[日期] = YesterdayDate, "昨天",《昨天之前》)返回报告日期
在您的过滤器中使用 Default_Date,您可以将 TODAY() 替换为
CALCULATE(Max(Table[Date]),All(Table))
并删除您不需要的内容.
如果你想获取所选项目的最后日期,那么
CALCULATE(Max(Table[Date]),ALLSELECTED(Table))
表格可能需要用引号引起来:'Table'[Date]
我希望这会有所帮助.
I want the Slicer in Power BI to select the most recent date of the selection to be selected automatically.
Here is an example of the drop down:
https://i.imgur.com/IykHSlI.png
This drop down differs from the Client selection.
I solved this issue the following way:
- I created one Report with a filter to Default_Date (which opens first)
- I used a Calculated Column [Default_Date] to populate the filter (which is hidden)
- In my case the user wanted to see Yesterday's data as the default date so I selected 'Yesterday' on my filter.
- Then I put a button that opens another duplicated copy of the Report [Hidden Tab] that contains a full calendar filter, so the user can select any other dates he likes, this hidden report has another button that returns the user to the main report [if he wants to].
picture of my filter (which I collapse and hide under a color box/banner)
Here is the formula for the calculated column (used in the filter):
Default_Date =
VAR TodaysDate =
TODAY()
VAR YesterdayDate =
TODAY() - 1
VAR reportDate =
SWITCH(TRUE(),
'Calendar'[Date] = TodaysDate, "Today",
'Calendar'[Date] = YesterdayDate, "Yesterday",
"Before Yesterday"
)
RETURN
reportDate
Use Default_Date in your filter, and you can replace TODAY() with
CALCULATE(Max(Table[Date]),All(Table))
and remove what you don't need.
If you want to get the Last Date of selected items, then
CALCULATE(Max(Table[Date]),ALLSELECTED(Table))
Table may need to be in quotes to work: 'Table'[Date]
I hope this helps.
这篇关于过滤器中的最近日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!