简体   繁体   English

Power BI:最近24小时和7天的切片器

[英]Power BI: Slicer for last 24 hours and 7 days

Gone through various forums and other similar questions but none has worked for me! 遍历各种论坛和其他类似问题,但没有一个对我有用!

I got Timestamp column in this format: DD:MM:YYY HH:MM:SS PM/AM 我得到了以下格式的时间戳列: DD:MM:YYY HH:MM:SS PM/AM

So how do I create a calculated column that dynamically evaluates the last 24 hours from the refresh time of 8:00 AM daily morning (ie, it should consider the last 24 hours from previous day 8:00 AM to refresh time 8:00 AM today. 因此,我如何创建一个计算列来动态评估每天早上8:00 AM的刷新时间以来的最后24小时(即,它应考虑从前一天8:00 AM到刷新时间8:00 AM的最近24小时)今天。

Likewise, the last 7 days too? 同样,最近7天呢?

I have tried following (for last 24 hours) which I got from https://community.powerbi.com/t5/Desktop/Only-show-last-24-hours-from-6am/td-p/109226 我尝试了以下操作(过去24小时),该操作来自https://community.powerbi.com/t5/Desktop/Only-show-last-24-hours-from-6am/td-p/109226
Power bi forum question. 电源碧论坛的问题。

Measure: 测量:

minTime = 
var temp= NOW()
return
if(HOUR(temp)>=8,temp,DATE(YEAR(temp),MONTH(temp),DAY(temp)-1)+TIME(8,MINUTE(temp),SECOND(temp)))

Table column: 表格栏:

New Table= FILTER(ALL(TABLE),[Date]>=[minTime]&&[Date]<=Now())

But it is giving me an error as 但这给了我一个错误

The expression refers to multiple columns. 该表达式引用多个列。 Multiple columns cannot be converted to a scalar value. 多个列不能转换为标量值。

Any help is much appreciated. 任何帮助深表感谢。

Try this - In my case I imported IIS logs after converting them to CSV files. 尝试此操作-就我而言,我将IIS日志转换为CSV文件后导入。

For me I think there was about 100 log files from 1/2 dz servers in the farm 对我来说,我认为服务器场中1/2 dz服务器中大约有100个日志文件

  1. Import your data 汇入资料
  2. The columns available were LogFilename RowNumber date time s-ip cs-method cs-uri-stem cs-uri-query s-port cs-username c-ip cs(User-Agent) sc-status sc-substatus sc-win32-status time-taken 可用的列为LogFilename RowNumber日期时间s-ip cs-方法cs-uri-stem cs-uri-query s-port cs-用户名c-ip cs(User-Agent)sc-状态sc-substatus sc-win32-状态所用的时间
  3. My Time value looked like this hh:mm:ss - but I wanted to get how many per hour 我的时间值看起来像这样:hh:mm:ss-但我想每小时获取多少

  4. Add a new column "PerHour = Hour(Teams[time])" - Teams is the table name and time is the column name and PerHour is the NEW column name Ref: https://msdn.microsoft.com/en-us/query-bi/dax/hour-function-dax 添加新列“ PerHour = Hour(Teams [time])”-Teams是表名称,time是列名称,PerHour是NEW列名称。参考: https ://msdn.microsoft.com/zh-cn/ query-bi / dax / hour-function-dax

Now I have a column and I can do a count for how may time the occurrence happened in that hour 现在我有一个专栏,我可以计算一下该小时发生的时间

屏幕截图

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM