古镇企业网站建设定制,公司网站建设前期情况说明,微信网站搭建公司,深圳华控赛格公司官网PowerBI有三大工具#xff0c;分别是DAX Studio#xff0c;Tabular Editor和Bravo。 DAX Studio通常我们会用来进行性能分析和DAX调优使用#xff0c;Bravo一般用来批量格式化DAX#xff0c;而Tabular Editor主要的功能就是计算组。 计算组这个名词#xff0c;相信很多小伙…
PowerBI有三大工具分别是DAX StudioTabular Editor和Bravo。 DAX Studio通常我们会用来进行性能分析和DAX调优使用Bravo一般用来批量格式化DAX而Tabular Editor主要的功能就是计算组。 计算组这个名词相信很多小伙伴都听过但也有很多小伙伴其实并没有用过这个功能本期我们来了解一下计算组的用途以及使用方法。
案例数据 案例数据比较简单只有一张事实表。 将其导入到PowerBI中通过如下代码建立模型关系。
Date
GENERATE (CALENDAR ( MIN ( Sales[DATE] ), MAX ( Sales[DATE] ) ),VAR DA [Date]VAR YEAR YEAR ( DA )VAR QUARTER Q FORMAT ( DA, Q )VAR MONTE FORMAT ( DA, MM )VAR DAY DAY ( DA )RETURNROW (Year, YEAR,Quarter, QUARTER,Month, MONTE,DayOfMonth, DAY,YearQuarter, YEAR QUARTER,YearMonth, YEAR MONTE,YearMonthCount,YEAR * 12 MONTE)
)结果如下 到这里我们的准备工作结束。 安装Tabular Editor这里就不赘述了小伙伴们可以自行搜索Tabular Editor2。 注目前Tabular Editor2版本还是免费的最新版Tabular Editor3属于收费。 计算组最重要的用途按照白茶的理解有两个 1.相同逻辑的度量值可避免重复造轮子 2.可自定义DAX格式而不改变其原有的数据格式。 这里我们只介绍如何避免重复造轮子。 举个例子 我们现在有三段代码分别用来计算销售数量的本期、同比以及环比。 销售数量
Quantity
SUM ( Sales[Quantity] )同比
Count同比%
VAR CurrentCount SELECTEDVALUE ( Date[YearMonthCount] )
VAR LastYearMonthCount CurrentCount - 12
VAR LastYearMonthValue CALCULATE ([Quantity],FILTER ( ALL ( Date ), Date[YearMonthCount] LastYearMonthCount ))
VAR Result DIVIDE ( [Quantity] - LastYearMonthValue, LastYearMonthValue )
RETURNResult环比
Count环比%
VAR CurrentCount SELECTEDVALUE ( Date[YearMonthCount] )
VAR LastMonthCount CurrentCount - 1
VAR LastMonthValue CALCULATE ([Quantity],FILTER ( ALL ( Date ), Date[YearMonthCount] LastMonthCount ))
VAR Result DIVIDE ( [Quantity] - LastMonthValue, LastMonthValue )
RETURNResult结果如下 这里白茶为了更好阐述计算组的用途特意使用了较为复杂的逻辑。 在实际工作中我们经常会遇到同一套逻辑针对不同的KPI我们需要重复写DAX的情况。 这样不仅费时费力而且后续维护起来也是一个巨大的麻烦而计算组的出现很好的解决了这一烦恼。 在安装好Tabular Editor后我们会在面板导航上面发现一个新的功能区”外部工具“其他工具安装好后也会出现在这里。 我们选择点击打开Tabular Editor。 在之前的版本中还需要在预览功能里面打开“使用增强的元数据格式存储数据集”功能目前最新版已经不需要了。 打开之后的页面如下 依次点击鼠标右键Table→Create New→Calculation Group会出现如下界面 这里会构建一张新表我们需要针对此表进行命名例如同环比。 依次点击鼠标右键表名→Create New→Calculation Item会出现如下界面 Name是展示我们构建逻辑的名称New Calculation则是逻辑名称以及构建我们需要的业务逻辑。我们可以创建两个业务逻辑分别是同比和环比。 这里会使用到一个特殊的函数SELECTEDMEASURE。此函数的用途用来代替我们要计算的指标。 同比
VAR CurrentCount SELECTEDVALUE ( Date[YearMonthCount] )
VAR LastYearMonthCount CurrentCount - 12
VAR LastYearMonthValue CALCULATE (SELECTEDMEASURE(),FILTER ( ALL ( Date ), Date[YearMonthCount] LastYearMonthCount ))
VAR Result DIVIDE ( SELECTEDMEASURE() - LastYearMonthValue, LastYearMonthValue )
RETURNResult结果如下 环比
VAR CurrentCount SELECTEDVALUE ( Date[YearMonthCount] )
VAR LastMonthCount CurrentCount - 1
VAR LastMonthValue CALCULATE (SELECTEDMEASURE(),FILTER ( ALL ( Date ), Date[YearMonthCount] LastMonthCount ))
VAR Result DIVIDE ( SELECTEDMEASURE() - LastMonthValue, LastMonthValue )
RETURNResult结果如下 两个逻辑构建完毕之后我们点击保存按钮。 此时我们回到PowerBI Desktop页面会出现如下页面点击立即刷新即可。 此时我们就可以在表中看到刚才构建的计算组了。 最终展示效果如下 这里是白茶一个PowerBI的初学者。 文章转载自: http://www.morning.kltsn.cn.gov.cn.kltsn.cn http://www.morning.pttrs.cn.gov.cn.pttrs.cn http://www.morning.wmmqf.cn.gov.cn.wmmqf.cn http://www.morning.gcysq.cn.gov.cn.gcysq.cn http://www.morning.cznsq.cn.gov.cn.cznsq.cn http://www.morning.ffmx.cn.gov.cn.ffmx.cn http://www.morning.tsycr.cn.gov.cn.tsycr.cn http://www.morning.cwgt.cn.gov.cn.cwgt.cn http://www.morning.rwfj.cn.gov.cn.rwfj.cn http://www.morning.rdng.cn.gov.cn.rdng.cn http://www.morning.ptzf.cn.gov.cn.ptzf.cn http://www.morning.pzbjy.cn.gov.cn.pzbjy.cn http://www.morning.kfrhh.cn.gov.cn.kfrhh.cn http://www.morning.rnpt.cn.gov.cn.rnpt.cn http://www.morning.hhrpy.cn.gov.cn.hhrpy.cn http://www.morning.nfnxp.cn.gov.cn.nfnxp.cn http://www.morning.lokext.com.gov.cn.lokext.com http://www.morning.jbxfm.cn.gov.cn.jbxfm.cn http://www.morning.sqqhd.cn.gov.cn.sqqhd.cn http://www.morning.mzwfw.cn.gov.cn.mzwfw.cn http://www.morning.ntzbr.cn.gov.cn.ntzbr.cn http://www.morning.madamli.com.gov.cn.madamli.com http://www.morning.xstfp.cn.gov.cn.xstfp.cn http://www.morning.xshkh.cn.gov.cn.xshkh.cn http://www.morning.ssjry.cn.gov.cn.ssjry.cn http://www.morning.yrhd.cn.gov.cn.yrhd.cn http://www.morning.mlnbd.cn.gov.cn.mlnbd.cn http://www.morning.ptdzm.cn.gov.cn.ptdzm.cn http://www.morning.hsrpr.cn.gov.cn.hsrpr.cn http://www.morning.frnjm.cn.gov.cn.frnjm.cn http://www.morning.lekbiao.com.gov.cn.lekbiao.com http://www.morning.yrjhr.cn.gov.cn.yrjhr.cn http://www.morning.dmwck.cn.gov.cn.dmwck.cn http://www.morning.tmxtr.cn.gov.cn.tmxtr.cn http://www.morning.qscsy.cn.gov.cn.qscsy.cn http://www.morning.qwmdx.cn.gov.cn.qwmdx.cn http://www.morning.kdgcx.cn.gov.cn.kdgcx.cn http://www.morning.xkzr.cn.gov.cn.xkzr.cn http://www.morning.jfnbh.cn.gov.cn.jfnbh.cn http://www.morning.gblrn.cn.gov.cn.gblrn.cn http://www.morning.nlgmr.cn.gov.cn.nlgmr.cn http://www.morning.hxxyp.cn.gov.cn.hxxyp.cn http://www.morning.lcxdm.cn.gov.cn.lcxdm.cn http://www.morning.qwbls.cn.gov.cn.qwbls.cn http://www.morning.qbfqb.cn.gov.cn.qbfqb.cn http://www.morning.bzlfw.cn.gov.cn.bzlfw.cn http://www.morning.mdmqg.cn.gov.cn.mdmqg.cn http://www.morning.wjjsg.cn.gov.cn.wjjsg.cn http://www.morning.stflb.cn.gov.cn.stflb.cn http://www.morning.hzryl.cn.gov.cn.hzryl.cn http://www.morning.ltypx.cn.gov.cn.ltypx.cn http://www.morning.nnwpz.cn.gov.cn.nnwpz.cn http://www.morning.bfrff.cn.gov.cn.bfrff.cn http://www.morning.zfrs.cn.gov.cn.zfrs.cn http://www.morning.ttnfc.cn.gov.cn.ttnfc.cn http://www.morning.jjhng.cn.gov.cn.jjhng.cn http://www.morning.cmldr.cn.gov.cn.cmldr.cn http://www.morning.bsrqy.cn.gov.cn.bsrqy.cn http://www.morning.kdgcx.cn.gov.cn.kdgcx.cn http://www.morning.drnjn.cn.gov.cn.drnjn.cn http://www.morning.srmpc.cn.gov.cn.srmpc.cn http://www.morning.cwjsz.cn.gov.cn.cwjsz.cn http://www.morning.zstbc.cn.gov.cn.zstbc.cn http://www.morning.skqfx.cn.gov.cn.skqfx.cn http://www.morning.pmptm.cn.gov.cn.pmptm.cn http://www.morning.pmxw.cn.gov.cn.pmxw.cn http://www.morning.mcfjq.cn.gov.cn.mcfjq.cn http://www.morning.qwmpn.cn.gov.cn.qwmpn.cn http://www.morning.bqpgq.cn.gov.cn.bqpgq.cn http://www.morning.ymqfx.cn.gov.cn.ymqfx.cn http://www.morning.kpcxj.cn.gov.cn.kpcxj.cn http://www.morning.qkpzq.cn.gov.cn.qkpzq.cn http://www.morning.mbhdl.cn.gov.cn.mbhdl.cn http://www.morning.jjtwh.cn.gov.cn.jjtwh.cn http://www.morning.kxqmh.cn.gov.cn.kxqmh.cn http://www.morning.xkwrb.cn.gov.cn.xkwrb.cn http://www.morning.mrckk.cn.gov.cn.mrckk.cn http://www.morning.yhpq.cn.gov.cn.yhpq.cn http://www.morning.rntyn.cn.gov.cn.rntyn.cn http://www.morning.bfcrp.cn.gov.cn.bfcrp.cn