0

Table-1 has:
Date                                         Number of Msgs
05-01-2015 12:45:26                      2
06-01-2015 16:48:00                      4
07-01-2015 10:15:25                      2
07-01-2015 11:30:21                      3
07-01-2015 12:30:25                      5
07-01-2015 13:15:00                      7
07-01-2015 13:30:00                      2
07-01-2015 13:45:00                      4
07-01-2015 14:00:00                      3

Now let's say the current system time is 14:05:00 on 07-01-2015

when I select Hour filter, the PowerView chart should display 'Number of Msgs' vs X-Axis (last one hour with 15 minutes interval).

when I select Day filter, the PowerView chart should display 'Number of Msgs' vs X-Axis (last 24 hours with 1 hour interval).

I am able to achieve Week filter, Month filter, Year filter. Struggling to get Day and Hour filters in place as it involves time section of a DateTime column.







[Day filter showing everything at 12:00:00AM] Image at: https://www.dropbox.com/s/uj7r8zugal9vx2n/day%20filter.JPG?dl=0



[for more details: manjunath.hireholi@gmail.com]

4

1 回答 1

0

这是一个 Power Query,它将日期分类为过去一小时和过去 ​​24 小时。您可以在 Excel 中选择您的表格,按 CTRL+T 使其成为表格,然后在 Power Query 选项卡上选择“从表格”。然后使用高级编辑器将默认查询替换为以下查询。只需仔细检查列名和表名。您提供的日期是将来的日期,因此您可以将 DateTime.FixedLocalNow() 替换为适当的日期。我没有以 15 分钟为间隔,但是使用您可以在此处阅读的电源查询日期功能应该可以快速完成:

https://support.office.com/en-us/article/Power-Query-formula-categories-125024ec-873c-47b9-bdfd-b437f8716819?CorrelationId=7e0cdea1-2b70-45c4-93ae-1037a351d004&ui=en-US&rs= en-US&ad=US

let
    Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
    #"Changed Type" = Table.TransformColumnTypes(Source,{{"Date                ", type datetime}}),
    #"Renamed Columns" = Table.RenameColumns(#"Changed Type",{{"Date                ", "Date"}, {"    Number of Msgs", "Number of Msgs"}}),
    #"Added Custom" = Table.AddColumn(#"Renamed Columns", "IsInLast24Hrs", each if(Duration.TotalHours(DateTime.FixedLocalNow() - [Date]) <= 24 and Duration.TotalHours(DateTime.FixedLocalNow() - [Date]) >=0 ) then 1 else 0),
    #"Added Custom1" = Table.AddColumn(#"Added Custom", "IsInLastHour", each if(Duration.TotalHours(DateTime.FixedLocalNow() - [Date]) <= 1 and Duration.TotalHours(DateTime.FixedLocalNow() - [Date]) >=0 ) then 1 else 0),
    #"Changed Type1" = Table.TransformColumnTypes(#"Added Custom1",{{"Number of Msgs", Int64.Type}, {"IsInLast24Hrs", Int64.Type}, {"IsInLastHour", Int64.Type}})
in
    #"Changed Type1"

感谢您使用 Power BI。

卢卡斯·P。

微软 Power BI 团队

如果您想及时了解 Power BI 开发人员故事更新,您可以注册 ( http://solutions.powerbi.com/appsuggestion.html ) 或关注我们的博客 ( http://blogs.msdn.com/ b/powerbitev/ )

于 2015-03-11T02:24:39.650 回答