Power BI:M與DAX以及度量與計算列

When I embarked on my Power BI journey I was almost immediately slapped with an onslaught of foreign and perplexing terms that all seemed to do similar, but somehow different, things.

當我開始Power BI之旅時,我幾乎立刻受到了外國和困惑術語的沖擊,這些術語似乎都在做著相似但有所不同的事情。

There is a language called M but there is also a language called DAX? What is the difference between a calculated column and a measure? When should I be using Power Query?

T 這里是一種叫做M的語言,但也有一種叫做DAX的語言? 計算列和度量之間有什么區別? 什么時候應該使用Power Query?

Image for post
Photo by Daniel Jensen on Unsplash
Daniel Jensen在Unsplash上拍攝的照片

I got stuck really early in my journey trying (and failing) to understand some key concepts that made Power BI seem much more difficult and confusing than it is. I almost abandoned my BI ambitions to crawl back to my familiar pal, Excel. Better the devil you know, right? WRONG!

我在嘗試(失敗)嘗試的過程中很早就陷入了困境,并且未能理解一些使Power BI看起來比實際困難和混亂的關鍵概念。 我幾乎放棄了我的BI野心,回到了我熟悉的朋友Excel。 更好的惡魔,對嗎? 錯誤!

I am so, so, SO happy that I kept banging my head against the wall to get over those initial hurdles. Today, I use Power BI almost daily, and I use it cheerfully, gleefully even, and I rarely use Excel. But getting here was hard, really hard. And it was harder than it should have been because, for a long time, I did not have a clear, conceptual understanding of some key Power BI concepts.

我是如此,如此,如此高興,我一直將頭撞在墻上以克服那些最初的障礙。 今天,我幾乎每天都在使用Power BI,并且愉快,愉快使用它,而我很少使用Excel。 但是到這里很難,真的很難。 而且這比原本應該的困難,因為很長一段時間以來,我對某些關鍵的Power BI概念沒有清晰的概念性理解。

I am going to try to keep things as simple as possible to give you just a hint, a tinge, a taste to get you started.

我將嘗試使事情盡可能簡單,以便給您一個提示淡淡色彩和使您入門的品味

More experienced Power BI users might cringe at the way I am (over) simplifying and reducing these concepts, but you know what? At this point, all of the nuance and minutia really doesn’t matter. You need a place to start. Trust me, the complexity will come.

經驗豐富的Power BI用戶可能會對我簡化和減少這些概念的方式感到畏縮,但是您知道嗎? 在這一點上,所有細微差別和細節都不重要。 您需要一個起點。 相信我,復雜性將會到來。

So, my intrepid warrior, my Padawan, my Power BI master-to-be, here is a very basic overview of:

因此,我的勇敢勇士,Padawan和Power BI未來的主人,這里是以下內容的非常基本的概述:

  1. Power Query and M

    功率查詢和M

  2. DAX

    達克斯

  3. Calculated Column and Measures

    計算列和度量

  4. Power Query vs. DAX

    電源查詢與DAX

Image for post
Photo by NeONBRAND on Unsplash
NeONBRAND在Unsplash上拍攝的照片

功率查詢和M (Power Query and M)

What the heck is it? This is where it all begins. Power Query is where you pull your data into Power BI. M is the coding language used by Powery Query. You can use Power Query by pointing and clicking and the code in M will essentially be created for you. You can also write your own code in M directly.

這到底是什么? 這就是一切的開始。 Power Query是將數據拉入Power BI的地方。 M是Powery Query使用的編碼語言。 您可以通過指向和單擊來使用Power Query,M中的代碼實際上將為您創建。 您也可以直接在M中編寫自己的代碼。

When do I use it? To clean and format your data. You can do things like remove and add columns, filter out data, change column formatting, etc.

什么時候使用? 清理和格式化數據。 您可以執行刪除和添加列,過濾數據,更改列格式等操作。

Do I have to use M?: Short answer, no. You can do most things in Power Query by pointing and clicking without needing to use M at all. However, knowing M can be really helpful in making your process more flexible and easier to replicate in the future. For example, when using M you can copy and paste bits of code you want to reuse and you can annotate your steps.

我必須使用M嗎? :簡短回答,不。 您可以通過指向和單擊來執行Power Query中的大多數操作,而根本不需要使用M。 但是,了解M確實可以使您的過程更靈活,將來更容易復制。 例如,使用M時,您可以復制和粘貼要重用的代碼位,并可以注釋步驟。

Tip for learning: Do what you need to in Power Query by pointing and clicking and then open the Advanced Editor. The M code will be there for the manipulations you have just completed. This way, you can start to get familiar with the language and by making small tweaks before you try writing your own M code from scratch.

學習提示 :指向并單擊,然后打開“ 高級編輯器” ,即可執行Power Query中需要執行的操作 M代碼將在其中用于您剛剛完成的操作。 這樣,在嘗試從頭開始編寫自己的M代碼之前,您可以進行一些細微的調整,從而開始熟悉該語言。

達克斯 (DAX)

What the heck is it? DAX, short for Data Analysis eXpressions, can be used to create measures and calculated columns once your data has been pulled into Power BI with Power Query/M.

這到底是什么? DAX是Data Analysis eXpressions(數據分析表達式)的縮寫,一旦將數據通過Power Query / M導入到Power BI中,即可用于創建度量和計算列。

When do I use it?: Using DAX is essentially like using formulas in Excel — it allows you to make calculations based on your data. You can use DAX to create calculated columns or measures.

我什么時候使用它?:使用DAX本質上類似于在Excel中使用公式-它使您可以根據數據進行計算。 您可以使用DAX創建計算列或度量。

計算列和度量 (Calculated Columns and Measures)

What the heck is it? Calculated columns and measures are two ways to write expressions in DAX. A calculated column will create an additional column with a value for every row in your table. A measure is an aggregate expression based on multiple rows in a table or multiple tables.

這到底是什么? 計算列和度量是在DAX中編寫表達式的兩種方法。 計算列將創建一個附加列,該附加列為表中的每一行提供一個值。 度量是基于一個表或多個表中的多行的聚合表達式。

When should I do a measure vs. a calculated column? I am so glad you asked because I really struggled with this one. This is a tricky one because you often can use either a measure or a calculated column (but that doesn’t mean you should).

什么時候應該進行度量與計算列比較? 您問我很高興,因為我真的很努力。 這是一個棘手的問題,因為您經常可以使用度量或計算列(但這并不意味著您應該使用)。

Things to keep in mind with measures and calculated columns:

度量和計算列要記住的事情:

  • When you can use either, use a measure

    當你可以使用,使用措施

  • A calculated column is typically used when you want to use it as a filter or slicer or if you want to create categories (e.g. add a column that has “New Employee,” “Employee”, or “Senior Employee” based on their tenure).

    當您想將其用作過濾器或切片器或要創建類別時,通常使用計算列 (例如,根據其任期添加具有“新雇員”,“雇員”或“高級雇員”的列) 。

  • You have to use a measure if you want to calculate something based on what the user has selected (e.g. calculating the total revenue for a department selected in a slicer)

    如果要基于用戶選擇的內容進行計算,則必須使用度量 (例如,計算在切片器中選擇的部門的總收入)

If the distinction between calculated columns and measures doesn’t totally make sense right now, that is okay. Try experimenting with creating both a measure and a calculated column and see if they both do what you need them to. If they do, great, use the measure. If just the calculated column works, go with that!

如果現在對計算列和度量之間的區別還不完全了解,那就可以了。 嘗試同時創建度量和計算列,以查看它們是否都滿足您的要求。 如果可以,那么請使用該措施。 如果只是計算出的列有效,那就繼續吧!

功率查詢(M)或DAX? (Power Query (M) or DAX?)

Things got confusing for me here, too, because it seemed like most of what I could do in Power Query/M, I could also do in DAX. Which one am I supposed to use and when?

這里的事情也讓我感到困惑,因為這似乎是我在Power Query / M中可以做的大多數事情,在DAX中也可以做到。 我應該使用哪一個?何時使用?

Short answer: Use Power Query/M when possible. (The big exception here is if you are trying to create a calculated column that references a column in a different table. In that case, use DAX to create a calculated column)

簡短答案 :盡可能使用Power Query / M。 (這里的最大例外是,如果您嘗試創建引用不同表中的列的計算列,在這種情況下,請使用DAX創建計算列)

Long answer: Read this.

長答案:請 閱讀 。

Image for post
Photo by Jingda Chen on Unsplash
陳靜 達在《 Unsplash》上的照片

And just like that, you did it! You made it through a basic conceptualization of Power Query, M, DAX, measures, and calculated columns. If you don’t understand all the differences and uses right now, that is perfectly okay! You have laid the foundation, and that is a huge step in the right direction.

就這樣,您做到了! 您通過對Power Query,M,DAX,度量計算列進行了基本概念化。 如果您現在不了解所有差異和用途,那完全可以! 您已經奠定了基礎,這是朝正確方向邁出的巨大一步。

要記住的事情: (Things to remember:)

  • Power Query is where it all begins to bring in and clean your data.

    Power Query是所有這些功能開始引入并清理您的數據的地方。
  • M is the language used in Power Query (you don’t have to use M directly, but it makes your life easier in the long run).

    M是Power Query中使用的語言(您不必直接使用M,但從長遠來看,它會使您的生活更輕松)。

  • DAX is the language used once your data is in Power BI to create calculated columns and measures.

    DAX是將數據放入Power BI中后用于創建計算列和度量的語言。
  • If you can do it in Power Query/M, you should (except when you are adding a column to a table that references a column in a different table).

    如果可以在Power Query / M中執行此操作,則應該這樣做 (將列添加到引用另一個表中的列的表中時除外)。

  • If a calculated column or a measure will work, use a measure.

    如果計算出的列或度量適用,請使用度量。

下一步: (Next steps:)

The easiest, and fastest, way to get these concepts to stick in your brain are by exposure and practice. Here are some great resources to get started with:

使這些概念深入大腦的最簡單,最快的方法是通過接觸和實踐。 這里有一些很好的入門資源:

  • SQLBI

    SQLBI

  • Microsoft PBI Learning

    Microsoft PBI學習

  • Power BI Community

    Power BI社區

While I highly encourage engaging with all the wonderful resources out there, nothing is going to help you more than by trying things out on your own and seeing what happens.

盡管我極力鼓勵與那里的所有寶貴資源合作,但沒有什么比通過自己嘗試和觀察會發生的事情對您有更多幫助。

Keep banging your head against the wall. It gets so much better.

繼續用力撞墻。 它變得好多了。

翻譯自: https://towardsdatascience.com/power-bi-m-vs-dax-vs-measures-4c77ae270790

本文來自互聯網用戶投稿,該文觀點僅代表作者本人,不代表本站立場。本站僅提供信息存儲空間服務,不擁有所有權,不承擔相關法律責任。
如若轉載,請注明出處:http://www.pswp.cn/news/388081.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/388081.shtml
英文地址,請注明出處:http://en.pswp.cn/news/388081.shtml

如若內容造成侵權/違法違規/事實不符,請聯系多彩編程網進行投訴反饋email:809451989@qq.com,一經查實,立即刪除!

相關文章

git 基本命令和操作

設置全局用戶名密碼 $ git config --global user.name runoob $ git config --global user.email testrunoob.comgit init:初始化倉庫 創建新的 Git 倉庫 git clone: 拷貝一個 Git 倉庫到本地 : git clone [url]git add:將新增的文件添加到緩存 : git add test.htmlgit status …

基于easyui開發Web版Activiti流程定制器詳解(三)——頁面結構(上)

上一篇介紹了定制器相關的文件,這篇我們來看看整個定制器的界面部分,了解了頁面結構有助于更好的理解定制器的實現,那么現在開始吧! 首先,我們來看看整體的結構: 整體結構比較簡單…

bzoj 4300 絕世好題 —— 思路

題目&#xff1a;https://www.lydsy.com/JudgeOnline/problem.php?id4300 記錄一下 mx[j] 表示以第 j 位上是1的元素結尾的子序列長度最大值&#xff0c;轉移即可。 代碼如下&#xff1a; #include<iostream> #include<cstdio> #include<cstring> #include&…

基于easyui開發Web版Activiti流程定制器詳解(四)——頁面結構(下)

&#xfeff;&#xfeff;題外話&#xff1a; 這兩天周末在家陪老婆和兒子沒上來更新請大家見諒&#xff01;上一篇介紹了調色板和畫布區的頁面結構&#xff0c;這篇講解一下屬性區的結構也是定制器最重要的一個頁面。 屬性區整體頁面結構如圖&#xff1a; 在這個區域可以定義工…

梯度下降法優化目標函數_如何通過3個簡單的步驟區分梯度下降目標函數

梯度下降法優化目標函數Nowadays we can learn about domains that were usually reserved for academic communities. From Artificial Intelligence to Quantum Physics, we can browse an enormous amount of information available on the Internet and benefit from it.如…

FFmpeg 是如何實現多態的?

2019獨角獸企業重金招聘Python工程師標準>>> 前言 眾所周知&#xff0c;FFmpeg 在解碼的時候&#xff0c;無論輸入文件是 MP4 文件還是 FLV 文件&#xff0c;或者其它文件格式&#xff0c;都能正確解封裝、解碼&#xff0c;而代碼不需要針對不同的格式做出任何改變&…

基于easyui開發Web版Activiti流程定制器詳解(五)——Draw2d詳解(一)

&#xfeff;&#xfeff;背景&#xff1a; 小弟工作已有十年有余&#xff0c;期間接觸了不少工作流產品&#xff0c;個人比較喜歡的還是JBPM&#xff0c;因為出自名門Jboss所以備受推崇&#xff0c;但是現在JBPM版本已經與自己當年使用的版本&#xff08;3.X&#xff09;大相徑…

Asp.net MVC模型數據驗證擴展ValidationAttribute

在Asp.Mvc項目中有自帶的一套完整的數據驗證功能&#xff0c;客戶端可以用HtmlHelper工具類&#xff0c;服務端可以用ModelState進行驗證。而他們都需要System.ComponentModel.DataAnnotations類庫中的特性功能&#xff0c;通過在屬性上方添加特性就可以達到驗證前后端驗證數據…

seaborn 子圖_Seaborn FacetGrid:進一步完善子圖

seaborn 子圖Data visualizations are essential in data analysis. The famous saying “one picture is worth a thousand words” holds true in the scope of data visualizations as well. In this post, I will explain a well-structured, very informative collection …

基于easyui開發Web版Activiti流程定制器詳解(六)——Draw2d的擴展(一)

&#xfeff;&#xfeff;題外話&#xff1a; 最近在忙公司的云項目空閑時間不是很多&#xff0c;所以很久沒來更新&#xff0c;今天補上一篇&#xff01; 回顧&#xff1a; 前幾篇介紹了一下設計器的界面和Draw2d基礎知識&#xff0c;這篇講解一下本設計器如何擴展Draw2d。 進…

深度學習網絡總結

1.Siamese network Siamese [sai? mi:z] 孿生 左圖的孿生網絡是指兩個網絡通過共享權值實現對輸入的輸出&#xff0c;右圖的偽孿生網絡則不共享權值(pseudo-siamese network)。 孿生神經網絡是用來衡量兩個輸入的相似度&#xff0c;可以用來人臉驗證、語義相似度分析、QA匹配…

異常檢測時間序列_時間序列的無監督異常檢測

異常檢測時間序列To understand the normal behaviour of any flow on time axis and detect anomaly situations is one of the prominent fields in data driven studies. These studies are mostly conducted in unsupervised manner, since labelling the data in real lif…

python設計模式(七):組合模式

組合&#xff0c;將對象組合成樹狀結構&#xff0c;來表示業務邏輯上的[部分-整體]層次&#xff0c;這種組合使單個對象和組合對象的使用方法一樣。 如描述一家公司的層次結構&#xff0c;那么我們用辦公室來表示節點&#xff0c;則總經理辦公司是根節點&#xff0c;下面分別由…

Django框架是什麼?

Django在新一代的Web框架中非常出色,為什么這么說呢&#xff1f;為回答該問題,讓我們考慮一下不使用框架設計Python網頁應用程序的情形.貫穿整本書,我們多次展示不使用框架實現網站基本功能的方法,讓讀者認識到框架開發的方便,&#xff08;不使用框架,更多情況是沒有合適的框架…

存款驚人_如何使您的圖快速美麗驚人

存款驚人So, you just finished retrieving, processing, and analyzing your data. You grab your data and you decide to graph it so you can show others your findings. You click ‘graph’ and……因此&#xff0c;您剛剛完成了數據的檢索&#xff0c;處理和分析。 您獲…

pytest自動化6:pytest.mark.parametrize裝飾器--測試用例參數化

前言&#xff1a;pytest.mark.parametrize裝飾器可以實現測試用例參數化。 parametrizing 1. 下面是一個簡單是實例&#xff0c;檢查一定的輸入和期望輸出測試功能的典型例子 2. 標記單個測試實例為失敗&#xff0c;例如使用內置的mark.xfail&#xff0c;則跳過該用例不執行直…

基于easyui開發Web版Activiti流程定制器詳解(六)——Draw2d詳解(二)

&#xfeff;&#xfeff;上一篇我們介紹了Draw2d整體結構&#xff0c;展示了組件類關系圖&#xff0c;其中比較重要的類有Node、Canvas、Command、Port、Connection等&#xff0c;這篇將進一步介紹Draw2d如何使用以及如何擴展。 進入主題&#xff1a; 詳細介紹一下Draw2d中幾個…

c#中ReadLine,Read,ReadKey的區別

Console.Read()、Console.ReadLine() 相同點&#xff1a; 1.兩者都是用于輸入的函數。 不同點&#xff1a; 1. Read只能讀取一個字符&#xff0c;ReadLine可以讀取一個字符串 如 Read讀取A和AASDGU的返回值都是一樣的 都為A的ASCII值&#xff0c;對于后續的ASDGU不理會。 而Rea…

Ubuntu16.04 開啟多個終端,一個終端多個小窗口

Ubuntu16.04 開啟多個終端&#xff0c;一個終端多個小窗口 CtrlShift T,一個終端開啟多個小終端 CtrlAlt T 開啟多個終端 posted on 2019-03-15 11:26 _孤城 閱讀(...) 評論(...) 編輯 收藏 轉載于:https://www.cnblogs.com/liuweijie/p/10535904.html

敏捷 橄欖球運動_澳大利亞橄欖球迷的研究聲稱南非裁判的偏見被證明是錯誤的

敏捷 橄欖球運動In February 2020, an Australian rugby fan produced a study, claiming to show how South African rugby referees were exhibiting favorable bias towards South African home teams. The study did not consider how other countries’ referees treat So…