Saturday 16 December 2023

DAX Query and Modelling Tut 1

 This is something very interesting,

We can to create a table that is called calendar in power bi. Now do we do that?
Yes, you are write, we will DAX. 

Year = DISTINCT(
    SELECTCOLUMNS(
        CALENDAR(DATE(1961, 1, 1), TODAY()),
        "Year", YEAR([Date])
    )
)


Another intuitive way of getting calendar is this:
EVALUATE
CALENDAR(DATE(2023 - 60, 1, 1), today())

Now we will create another calculated column in the same year table and we will call it millenium.
Millenium = 'Year'[Year] - MOD('Year'[Year], 1000) What does the MOD represent here? MOD stands for Modulus here. Modulus is whatever is left after attempt of division. In this case, the division result cannot be of any other data type but a whole number.


Century = 'year'[Year] - MOD('Year'[Year], 100)

We want to test the DAX Measures, you can use the DAX Query View in order to test measures or calculated columns.

EVALUATE
   SUMMARIZECOLUMNS("whatever", MOD(5, 2))

Now, lets create a Decade column. Put your code in the comment below.


))