Author: CB

  • DAX Code Examples

    DAX Code Examples

     DAX Code Examples:1. Using Variables2. FORMAT()3. HASONEVALUE()4. AND, &&5. CALCULATETABLE() and SUMMARIZE()6. USERELATIONSHIP()7. SWITCH()8. ISFILTERED() and making visual transparent9. SELECTEDVALUE() and creating a dynamic Graph Title10. FILTER and ADDCOLUMNS11. RANK() VAR: Using Variables Running Total = VAR MaxDateInFilterContext = MAX ( Dates[Date] ) //variable 1 max date#VAR MaxYear = YEAR ( MaxDateInFilterContext ) //variable 2…

  • Lists in Python

    Lists in Python

    Create a listSimple listmylist = [“apple”, “orange”, “banana”, “mango”, “pineapple”]mylist[2] # returns ‘banana’mylist[-1] # returns ‘pineapple’mylist[2:4] #returns ‘banana’, ‘mango’, ‘pineappleif “apple” in thislist:  print(“Yes, ‘apple’ is in the fruits list”)mylist.insert(2, “watermelon”) #insert at position speifiedmylist.append(‘grapes’) #adds to end of listmylist = [“apple”, “banana”, “cherry”]tropical = [“mango”, “pineapple”, “papaya”]mylist.extend(tropical) # adds tropical list to thislistmy.remove(“banana”) #removes first occurrencemylist.pop(1) #removes specified instancedel mylist[0] #also removes instancedel mylist…

  • Linear Regression

    Linear Regression

    Linear Regression using Salary and Years of Experience Data Data Source: Salary_dataset.csv KaggleThe salary data set includes 2 columns: Years Experience which will be our independent variable (X) and Salary (Y). Linear regression is a fundamental statistical method used to model the relationship between a dependent variable and one or more independent variables. The primary…

  • Pandas Code

    Pandas Code

    Pandas Quick Guide Modules import pandas as pd #pandas moduleimport scipy.stats as stats #stats sub-modulefrom bs4 import BeautifulSoup #scrape moduleimport requests #API moduleimport whois as whois #whois module Filesdf = pd.read_csv(“CookieData.csv”) #import CSV file to dataframe df #define index column and convert dates to date format air_quality = pd.read_csv(“air_quality_long.csv”, index_col=”date.utc”, parse_dates=True) air_quality.to_csv(“checkcombine.csv”) #save dataframe to…

  • T-Test

    T-Test

    by

    in

    In business, the most commonly used t-test is often the Independent Two-Sample t-test. This test is widely utilized to compare the means of two independent groups or samples to determine if there is a significant difference between them. The Independent Two-Sample t-test is particularly useful in various business scenarios, such as: Purpose: Example: 2. Independent…

  • Working with Dates in BigQuery

    Working with Dates in BigQuery

    References: Date Functionshttps://cloud.google.com/bigquery/docs/reference/standard-sql/date_functionsFormat Elementshttps://cloud.google.com/bigquery/docs/reference/standard-sql/format-elements#format_elements_date_timeCurrent Date, Last_Date, Construction Add and Subtract FORMAT_DATE and PARSE_DATE EXTRACT DATE_DIFF DATE() Constructor DATE TRUNC()

  • DAX Running Total Quick Measure vs. Human Measure

    DAX Running Total Quick Measure vs. Human Measure

    Dax Running TotalAn example we start of we a sales and date table to crate our running table sales from. We start by creating a sales measure as follows: Sales = SUM(FactSales[SalesAmount]) Next we create a quick measure to create the ;Running Total in Sales’ and add it to our table: The Code for the…

  • SQL Code for Lifetime Value Model

    SQL Code for Lifetime Value Model

    The first part of building the code to pull the data for the lifetime value model is to create an SQL script that will get the historical data we need to train our model on. The SQL Code select 6 fields from the Contoso Retail Datawarehouse:The full SQL code is at the bottom of the…

  • Building a Human Resources Employee Attrition Model

    Building a Human Resources Employee Attrition Model

    Here we make use of the HR Analytics dataset available on Kagoo. The dataset was created to understand the factors behind employee attrition and can be used to train a model for predicting employee churn. The Python Code for the 2 models is on Github We can start by importing the required libraries and import…

  • Building an Survey Results Report with Power BI

    Building an Survey Results Report with Power BI

    Power BI can be useful for displaying and storing survey results for your organization. In this example we build some data for the results of a fictitious Airline survey, using questions taken from a real online airport survey. The data was built in Excel with a sheet for questions and a sheet for answers. You…