Forum Discussion

richard-powerbi's avatar
richard-powerbi
Icon for Post Patron rankPost Patron
6 years ago
Solved

Calculate between different granularities

  So I have above datamodel. A (highest granularity) has multiple rows of B, and B has multiple rows of C (lowest granularity). See below data structure. I'm trying to make measures th...
  • Anonymous's avatar
    Anonymous
    6 years ago

    Hi there.

     

    The key to good Power BI reports is a sound and simple model. Power Query (M) can also be optimized like DAX but one has to know HOW. Please read the documentation on the M language, read about eager and lazy evaluation rules and apply them wisely. A good source of information on Power Query and M is Chris Webb's blog at

     

    https://blog.crossjoin.co.uk/

     

    and also this tutorial

     

    https://bengribaudo.com/blog/2017/11/17/4107/power-query-m-primer-part1-introduction-simple-expressions-let

     

    I have read this all and know how to optimize M so that it's blazingly fast. I suggest you do the same. Moving data mashup operations into DAX is never the way to go unless... you want to get into deep, deep trouble later on; it's like a time bomb that will blow up rather sooner than later.

     

    Also, please note that if you don't use the dimensional design (separating dims and facts), you'll sooner or later be producing wrong numbers. This is due to the fact that SUMMARIZECOLUMNS optimizes the retrieval of attributes from tables using the auto-exist feature (read upon auto-exist in DAX on www.sqlbi.com; just use the search engine on the page).

    Secondly, the golden rule of dimensional modeling is this:

     

    Your dimensions should be short but wide and your fact tables should be narrow but long.

     

    There's NO EXCEPTION TO THIS.

     

    Now, please look at the attached file. It has a model as it should be set up and enables you to calculate everything you need simply and fast. This IS exactly how it should be done. You won't get anything better in terms of speed and simplicity.

     

    Please try to learn how to optimize operations in M. Do not shoot yourself in the foot.

     

    Best
    D