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.


))

Monday 17 July 2023

Friday 16 June 2023

Filtering using pandas


This code will filter the rows where the 'Year' column is 2017 and select only the 'Year' and 'Revenue (GBP Millions)' columns. It will print the filtered rows with the corresponding values for both columns.

Make sure to replace 'Year' and 'Revenue (GBP Millions)' with the actual column names in your dataframe. If you have more columns that you want to include in the filtered result, you can add them within the double square brackets, separated by commas.

Note: If you want to perform any calculations or further data analysis on the filtered data, it's recommended to assign it to a new variable, like filtered_data, rather than modifying the original dataframe directly.

filtered_data = df[df['Year'] == 2017][['Year', 'Revenue (GBP Millions)']]

print(filtered_data)