我是DAX新手并且有关于过滤措施的问题。正如您在附件中看到的那样,我希望仅针对2018年过滤这两个度量volume CY
(当前年份)和volume LY
。
Volume LY Volume CY
2016 65.024.635
2017 65.024.635 63.602.450
2018 63.602.450 21.597.407
我想将过滤与指标(Counter
)相关联。该计数器的值在[0-3]范围内。每年都有学期,例如当前年度有2017年第1学期和第1学期 - 2016年第2期和第3期 - 4年和第5期。在这种情况下,我想为计数器选择1,它应该过滤semester <= 1
2018年:
Volume LY Volume CY
2018 63.602.450 21.597.407
但是,如果我使用:
过滤度量volume CY
FILTER(ALLSELECTED(Table);Table[Semester]<=MAX('Table2'[Counter]));
然后测量Volume LY
会自动过滤semester <= 1
并且它不会显示LY的值。我的问题是:我如何使用过滤函数来获取当年的两种度量值?
测量当前体积年度:
Volume_CY:=CALCULATE(
[Volume];
'Scenario'[Scenario1]=1;
FILTER(Table;Table[Semester]<=MAX('Table2'[Counter])))
测量体积LY:
Volume LY:= CALCULATE(
[Volume_CY];
FILTER(ALLSELECTED(Table);Table[Semester]<=MAX('Table2'[Counter]));
FILTER(ALL(Table[Year]))
以下是计数器1和方案1的两个测量结果:正如您所看到的,它没有显示LY值,应该是63.602.450。
Scenario 1
Counter 1
Volume LY Volume CY
2018 21.597.407
Total 21.597.407
现在我有这样的结果:
Volume CY Volume LY
20151 77.222.12 77.222.12
20152 88.868.719 88.868.719
20161 87.987.22 87.987.22
20162 92.906.793 92.906.793
20171 101.102.12 101.102.12
20172 105.029.725 105.029.725
这就是我所期待的:
Volume CY Volume LY
20151 77.222.12
20152 88.868.719 49.123.12
20161 87.987.22 77.222.12
20162 92.906.793 88.868.719
20171 101.102.12 87.987.22
20172 105.029.725 92.906.793
答案 0 :(得分:0)
修改强>
给出以下源数据:
year, Volume CY
20151, 77222.12
20152, 88868.719
20161, 87987.22
20162, 92906.793
20171, 101102.12
20172, 105029.725
使用以下计算列可以实现预期结果:
Volume LY = CALCULATE(SUM(Table[Volume CY]),
ALL(Table1),
Table[year] = EARLIER(Table[year])-10)
结果是:
year, Volume CY, Volume LY
20151, 77222.12,
20152, 88868.719,
20161, 87987.22, 77222.12
20162, 92906.793, 88868.719
20171, 101102.12, 87987.22
20172, 105029.725, 92906.793
哪个过滤&#34; year
&#34;列。
(下面的旧答案)
滚动总和:
year semester volume
2016 1 123
2017 3 1345
2018 5 3465
2016 2 3465
2017 4 3465
2018 6 634
计算列:
VCY = CALCULATE(SUM(Table1[volume]),
ALL(Table1),
Table1[semester] <= EARLIER(Table1[semester]))
VLY = CALCULATE(SUM(Table1[volume]),
ALL(Table1),
Table1[semester] <= EARLIER(Table1[semester]) - 2)
结果:
year, semester, volume, VCY, VLY
2016, 1, 123, 123,
2016, 2, 3465, 3588,
2017, 3, 1345, 4933, 123
2017, 4, 3465, 8398, 3588
2018, 5, 3465, 11863, 4933
2018, 6, 634, 12497, 8398
每年滚动总和:
VCY =
VAR RowYear = Table1[year]
RETURN CALCULATE(SUM(Table1[volume]),
ALL(Table1),
table1[year] = RowYear,
Table1[semester] <= EARLIER(Table1[semester]))
VLY =
VAR RowYear = Table1[year]-1
RETURN
CALCULATE(SUM(Table1[volume]),
ALL(Table1),
table1[year] = RowYear,
Table1[semester] <= EARLIER(Table1[semester])-2)
结果:
year, semester, volume, VCY, VLY
2016, 1, 123, 123,
2016, 2, 3465, 3588,
2017, 3, 1345, 1345, 123
2017, 4, 3465, 4810, 3588
2018, 5, 3465, 3465, 1345
2018, 6, 634, 4099, 4810
答案 1 :(得分:0)
结果如下:
#!/usr/bin/env python
import os
import subprocess
import psutil
def getBatteryLevel():
BATTERY_CMD = ["/usr/sbin/ioreg", "-l"]
GREP_CMD = ["/usr/bin/egrep", "Capacity|ExternalChargeCapable"]
process = subprocess.Popen(BATTERY_CMD, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
grep = subprocess.Popen(GREP_CMD, stdin=process.stdout, stdout=subprocess.PIPE, stderr=subprocess.PIPE)
grep.wait()
output = grep.communicate()[0]
batteryStatus = output.split("\n")
maxCapacity = float(batteryStatus[1].split("=")[1].lstrip())
curCapacity = float(batteryStatus[2].split("=")[1].lstrip())
remaining = 100 * (curCapacity / maxCapacity)
print "BATTERY LEVEL : "
print remaining
getBatteryLevel()
这就是我所期待的:
Volume CY Volume LY
20151 77.222.12 77.222.12
20152 88.868.719 88.868.719
20161 87.987.22 87.987.22
20162 92.906.793 92.906.793
20171 101.102.12 101.102.12
20172 105.029.725 105.029.725
如果我按特定年份/半年过滤,例如20162它应该显示以下内容:
Volume CY Volume LY
20151 77.222.12
20152 88.868.719 49.123.12
20161 87.987.22 77.222.12
20162 92.906.793 88.868.719
20171 101.102.12 87.987.22
20172 105.029.725 92.906.793
这就是我所得到的:`过滤器(全部(表);表(年)= MAX(表(年)-10)) - &gt; 缺少卷CY的总计!
Volume CY Volume LY
20162 92.906.793 88.868.719