{"id":1530,"date":"2022-08-09T07:42:50","date_gmt":"2022-08-09T05:42:50","guid":{"rendered":"https:\/\/www.tefipro.com\/?p=1530"},"modified":"2024-07-04T17:45:27","modified_gmt":"2024-07-04T15:45:27","slug":"document-in-power-bi","status":"publish","type":"post","link":"https:\/\/www.tefipro.com\/en\/document-in-power-bi\/","title":{"rendered":"Document in Power BI"},"content":{"rendered":"\n<p>Power BI is a great platform with amazing capabilities. However, it also has its dark areas, and in my opinion, one of them is how to document calculations and model logic.<\/p>\n\n\n\n<p>In simple projects, it can be managed without documentation. But in complex projects, with specific metrics and involving multiple people, it becomes more necessary. Therefore, the efforts put into documentation should be rewarded in the medium term.<\/p>\n\n\n\n<p>At TEFIPRO, we encounter the situation described above: several people work on a project as it evolves, with very specific metrics that are sometimes beyond general understanding.<\/p>\n\n\n\n<p>As far as we know, there are no guidelines established by any relevant entity or widely accepted by the community. Therefore, this entry aims to share how we do it. (It doesn&#8217;t have to be the best way, but it is useful for us.)<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Use of Variables<\/strong><\/p>\n\n\n\n<p>Variables are useful from the efficiency perspective in calculations but also to break down the code into smaller steps, making the calculation more progressive and understandable.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"737\" height=\"375\" src=\"https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-1.png\" alt=\"\" class=\"wp-image-1533\" srcset=\"https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-1.png 737w, https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-1-300x153.png 300w, https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-1-400x204.png 400w\" sizes=\"auto, (max-width: 737px) 100vw, 737px\" \/><\/figure>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Variable Names<\/strong><\/p>\n\n\n\n<p>Variables have some limitations from a &#8216;naming&#8217; perspective, primarily that they cannot contain spaces. With the goal of making our code readable, our approach is as follows:<\/p>\n\n\n\n<p>Use descriptive names: Initial analysis date (fecha inicial de an\u00e1lisis)<\/p>\n\n\n\n<p>Use the underscore character to allow multiple words in the variable name: Initial_analysis_date<\/p>\n\n\n\n<p>Use capital letters at the beginning of words: Initial_Analysis_Date<\/p>\n\n\n\n<p>The third point is more open to debate, but personally, it helps me read and understand the variable more quickly. DAX, the language of Power BI, is not case-sensitive, so this third point won&#8217;t cause errors if we forget to capitalize while writing the formula.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Comments<\/strong><\/p>\n\n\n\n<p>Making precise comments in the code helps with future understanding and also allows for clarifying ideas during development.<\/p>\n\n\n\n<p>When the metric is very specific, it is useful to describe it at the beginning.<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"886\" height=\"250\" src=\"https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-2.png\" alt=\"\" class=\"wp-image-1535\" srcset=\"https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-2.png 886w, https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-2-300x85.png 300w, https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-2-768x217.png 768w, https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-2-400x113.png 400w\" sizes=\"auto, (max-width: 886px) 100vw, 886px\" \/><\/figure>\n\n\n\n<p>At the variable level, you can also specify details through comments, such as indicating units or other hints that help maintain the code in the future.<\/p>\n\n\n\n<p class=\"has-medium-font-size\"><strong>Formatting and Indentation<\/strong><\/p>\n\n\n\n<p>Using indentation properly contributes to the goal of making our code more understandable and also helps avoid errors with &#8216;(&#8216; &#8230; &#8216;)&#8217; or &#8216;,&#8217;<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"886\" height=\"270\" src=\"https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-3.png\" alt=\"\" class=\"wp-image-1537\" srcset=\"https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-3.png 886w, https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-3-300x91.png 300w, https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-3-768x234.png 768w, https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-3-400x122.png 400w\" sizes=\"auto, (max-width: 886px) 100vw, 886px\" \/><\/figure>\n\n\n\n<p>In contrast to:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full\"><img loading=\"lazy\" decoding=\"async\" width=\"886\" height=\"40\" src=\"https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-4.png\" alt=\"\" class=\"wp-image-1539\" srcset=\"https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-4.png 886w, https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-4-300x14.png 300w, https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-4-768x35.png 768w, https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/07\/image-4-400x18.png 400w\" sizes=\"auto, (max-width: 886px) 100vw, 886px\" \/><\/figure>\n\n\n\n<p>To start organizing indentation properly, tools like&nbsp;<a href=\"https:\/\/www.daxformatter.com\/\" target=\"_blank\" rel=\"noopener\">https:\/\/www.daxformatter.com\/<\/a> can be used. In our experience, after using this tool a couple of times, you naturally start writing with correct formatting, making any additional tool unnecessary.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Power BI is a great platform with amazing capabilities. However, it also has its dark areas, and in my opinion, one of them is how to document calculations and model logic. In simple projects, it can be managed without documentation. But in complex projects, with specific metrics and involving multiple people, it becomes more necessary. [&hellip;]<\/p>\n","protected":false},"author":6,"featured_media":1061,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_acf_changed":false,"_curso_id":0,"_orden":0,"_duracion_minutos":0,"_tipo_contenido":"","_es_completable":"","_video_url":"","_audio_url":"","_documento_id":0,"_uag_custom_page_level_css":"","_genesis_hide_title":false,"_genesis_hide_breadcrumbs":false,"_genesis_hide_singular_image":false,"_genesis_hide_footer_widgets":false,"_genesis_custom_body_class":"","_genesis_custom_post_class":"","_genesis_layout":"","footnotes":""},"categories":[53,1,60],"tags":[],"class_list":{"0":"post-1530","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-big-data","8":"category-news","9":"category-power-bi","10":"entry"},"acf":[],"uagb_featured_image_src":{"full":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image.jpg",391,244,false],"thumbnail":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image-300x244.jpg",300,244,true],"medium":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image-300x187.jpg",300,187,true],"medium_large":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image.jpg",391,244,false],"large":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image.jpg",391,244,false],"1536x1536":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image.jpg",391,244,false],"2048x2048":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image.jpg",391,244,false],"gur_featured_image":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image.jpg",391,244,false],"gur_blog_thumbnail":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image-385x240.jpg",385,240,true],"gur_casos_thumbnail":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image.jpg",391,244,false],"gur_casos_service_thumbnail":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image.jpg",391,244,false],"gur_casos_industry_thumbnail":["https:\/\/www.tefipro.com\/wp-content\/uploads\/2024\/06\/image.jpg",391,244,false]},"uagb_author_info":{"display_name":"TEFIPRO","author_link":"https:\/\/www.tefipro.com\/en\/author\/tefipro\/"},"uagb_comment_info":0,"uagb_excerpt":"Power BI is a great platform with amazing capabilities. However, it also has its dark areas, and in my opinion, one of them is how to document calculations and model logic. In simple projects, it can be managed without documentation. But in complex projects, with specific metrics and involving multiple people, it becomes more necessary.&hellip;","_links":{"self":[{"href":"https:\/\/www.tefipro.com\/en\/wp-json\/wp\/v2\/posts\/1530","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tefipro.com\/en\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tefipro.com\/en\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tefipro.com\/en\/wp-json\/wp\/v2\/users\/6"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tefipro.com\/en\/wp-json\/wp\/v2\/comments?post=1530"}],"version-history":[{"count":2,"href":"https:\/\/www.tefipro.com\/en\/wp-json\/wp\/v2\/posts\/1530\/revisions"}],"predecessor-version":[{"id":1543,"href":"https:\/\/www.tefipro.com\/en\/wp-json\/wp\/v2\/posts\/1530\/revisions\/1543"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.tefipro.com\/en\/wp-json\/wp\/v2\/media\/1061"}],"wp:attachment":[{"href":"https:\/\/www.tefipro.com\/en\/wp-json\/wp\/v2\/media?parent=1530"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tefipro.com\/en\/wp-json\/wp\/v2\/categories?post=1530"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tefipro.com\/en\/wp-json\/wp\/v2\/tags?post=1530"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}