如何在Power BI中将HOUR转换为BETWEEN_HOUR之间?

时间:2020-05-02 12:56:34

标签: powerbi powerbi-desktop powerbi-datasource power-bi-report-server powerbi-custom-visuals

我有表格HOUR列

HOUR
1
2
3

就像这样,但我们需要转换成

BETWEEN_HOUR
01:00 - 02:00
02:00 - 03:00
03:00 - 04:00

如何实现相同

2 个答案:

答案 0 :(得分:0)

我们必须按照下面的方式进行转换

Table.AddColumn(#"Expanded Column1", "BETWEEN_HOUR", each  (Text.From((HOUR]) &  ':00  - '  &
Text.From([HOUR] + 1) &  ":00"))

输出:

BETWEEN_HOUR
01:00 - 02:00
02:00 - 03:00
03:00 - 04:00

答案 1 :(得分:0)

我们可以使用高级编辑器和自定义列来使用条件规则来得出条件。

if [HOUR] = 24 then "00:00 - 01:00"
else if [HOUR] = 25 then "01:00 - 02:00"
else if [HOUR] = 26 then "02:00 - 03:00"
else if [HOUR] = 27 then "03:00 - 04:00"
else if [HOUR] = 28 then "04:00 - 05:00"
else if [HOUR] = 29 then "05:00 - 06:00"
else if [HOUR] = 30 then "06:00 - 07:00"
else if [HOUR] = 31 then "07:00 - 08:00"
else if [HOUR] = 8 then "08:00 - 09:00"
else if [HOUR] = 9 then "09:00 - 10:00"
else if [HOUR] = 10 then "10:00 - 11:00"
else if [HOUR] = 11 then "11:00 - 12:00"
else if [HOUR] = 12 then "12:00 - 13:00"
else if [HOUR] = 13 then "13:00 - 14:00"
else if [HOUR] = 14 then "14:00 - 15:00"
else if [HOUR] = 15 then "15:00 - 16:00"
else if [HOUR] = 16 then "16:00 - 17:00"
else if [HOUR] = 17 then "17:00 - 18:00" |
else if [HOUR] = 18 then "18:00 - 19:00"
else if [HOUR] = 19 then "19:00 - 20:00"
else if [HOUR] = 20 then "20:00 - 21:00"
else if [HOUR] = 21 then "21:00 - 22:00"
else if [HOUR] = 22 then "22:00 - 23:00"
else if [HOUR] = 23 then "23:00 - 24:00"
else null

结果:

enter image description here