DAX基于日期字段测量月变量

时间:2018-01-31 22:20:25

标签: powerbi dax powerpivot

我很难让以下措施奏效。我正在尝试根据日期过滤器更改目标。我的过滤器是Workday列,其中Workday是标准日期列。 sMonth是一个月份列,格式为整数。我希望保持切片器的粒度,以便白天工作,添加月份和年份的自定义列,并将这些度量基于这些将有所帮助。这是我尝试过的,无法让它发挥作用:

Cars Inspected = 
VAR
selectedMonth = MONTH(SELECTEDVALUE('All Cars Inspected'[Workday]))
RETURN CALCULATE(SUM(Targets[Target]),
    FILTER(Targets,Targets[Location]="Texas"),
    FILTER(Targets,Targets[Description]="CarsInspected"),
    FILTER(Targets,Targets[sMonth]=selectedMonth))

如果有人建议采用不同的方法来实现相同的结果,我将不胜感激。

LE

这是我想要实现的模型:

enter image description here

工作日过滤了总车数。我想让目标/范围充满活力。调整滑块后,其他所有内容都会调整。

我的表格如下:

+-----------+--------------------+----------+
|  Workday  | TotalCarsInspected | Location |
+-----------+--------------------+----------+
| 4/4/2017  |                  1 | Texas    |
| 4/11/2017 |                149 | Texas    |
| 4/12/2017 |                129 | Texas    |
| 4/13/2017 |                201 | Texas    |
| 4/14/2017 |                  4 | Texas    |
| 4/15/2017 |                  6 | Texas    |
+-----------+--------------------+----------+

+----------+--------+----------+---------------+--------+-----+--------+
| TargetID | sMonth | Location |  Description  | Target | Red | Yellow |
+----------+--------+----------+---------------+--------+-----+--------+
|      495 |      1 | Texas     | CarsInspected |   3636 | 0.5 | 0.75  |
|      496 |      2 | Texas     | CarsInspected |   4148 | 0.5 | 0.75  |
|      497 |      3 | Texas     | CarsInspected |   4861 | 0.5 | 0.75  |
|      498 |      4 | Texas     | CarsInspected |   4938 | 0.5 | 0.75  |
|      499 |      5 | Texas     | CarsInspected |   5094 | 0.5 | 0.75  |
|      500 |      6 | Texas     | CarsInspected |   5044 | 0.5 | 0.75  |
|      501 |      7 | Texas     | CarsInspected |   5043 | 0.5 | 0.75  |
|      502 |      8 | Texas     | CarsInspected |   4229 | 0.5 | 0.75  |
|      503 |      9 | Texas     | CarsInspected |   4311 | 0.5 | 0.75  |
|      504 |     10 | Texas     | CarsInspected |   4152 | 0.5 | 0.75  |
|      505 |     11 | Texas     | CarsInspected |   3592 | 0.5 | 0.75  |
|      506 |     12 | Texas     | CarsInspected |   3748 | 0.5 | 0.75  |
+----------+--------+----------+---------------+--------+-----+--------+

1 个答案:

答案 0 :(得分:1)

让您的仪表的值为connect to: 52.88.14.46:8333 writeMessage: version header: f9beb4d976657273696f6e00000000006100000061000000 payload: 7c9c000001000000000000005a73788200000000524543495049454e54204950000000000000000000000000000053454e44455220495000000000000000000000000000000000006237646465346163626f657463686169000000000000000000 readMessage read: -1 END OF CONNECTION! Shutting down.... 的总和,并将最大值设置为以下度量:

TotalCarsInspected