Forum Discussion

6 Replies

  • prabhuk for any date-related calculations, you must add a date dimension in your model, and to add one, you can look at my post here.

     

    once this table is there, change all your measures to use date from this new date table instead of from your sales table and it will all work.

     

    Check my latest blog post Year-2020, Pandemic, Power BI and Beyond to get a summary of my favourite Power BI feature releases in 2020

    I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

    Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.

  • Hi,

    Your tables and relationships are not properly set up.  You should create a Calendar Table and build a relationship from the Date columns of the Budget and Sales table to the Date column of the Calendar Table.  The region column of the Budget and Sales table should also be connected to the Region column of the Region table.  There should be no relationship between the Budget and Sales table.  Any time period related slicer (Year/Month Name) should be dragged from the Calendar Table.

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    I agree you should add a Date table to your model.  FYI that you can do your calculation without one (but you really should add one).  Here is an example.  Also, FYI that you don't need to wrap all your measures in CALCULATE, only when you need to change the evaluation context (like your previous year calculations).

     

    FY20 2 =
    VAR vThisYear =
        YEAR (
            TODAY ()
        )
    RETURN
        CALCULATE (
            SUM ( Sales[Sales] ),
            FILTER (
                ALL ( Sales[DATE] ),
                YEAR ( Sales[DATE] ) = vThisYear - 1
            )
        )

     

    Pat

     

  • prabhuk I know mahoneypat  gave the solution without a date table but I will never go that route Make a habit to add a date dimension in your model and perform all time intelligence based calculations based on this dimension. There is a reason why it needs to be in the model.

     

    Just my 2 cents.