Introduction to Customer Churning

Comparing R and Powerbi DAX

Author

Bongani Ncube

Published

23 April 2024

Note
  • this blog aims to compare how things are done in R and Powerbi

Data Analysis Expressions (DAX) is a formula expression language used in Analysis Services, Power BI, and Power Pivot in Excel. DAX formulas include functions, operators, and values to perform advanced calculations and queries on data in related tables and columns in tabular data models.

  • This article provides only a basic introduction to the most important concepts in DAX while comparing them to R
library(tidyverse)

churn<-readr::read_csv("Databel_Data.csv")
churn |> 
  head(10) |> 
  flextable::flextable()

Data exploration

Note
  • before any analysis , it is mandatory to learn more about the rows in our data
  • things like the number of rows in our data and duplicate columns in our data are very important to understand

Data manipulation

IF STATEMENTS

Calculate churn Rate

for that we first calculate the number of customers that churned ,

Lets determine the frequent reasaons for churning

More advanced data manipulation

table(churn$`Contract Type`)

Month-to-Month       One Year       Two Year 
          3411           1479           1797 

suppose we intend to have just year and Monthly contract types , we can choose to bundle up One year and Two Year into just Year category.

Churn Rates By state

Filtering

  • filtering is a common pocedure in data science

here is how we do it in R as compared to DAX