This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //SPEC | |
| { | |
| "data": { | |
| "name": "dataset" | |
| }, | |
| "title": "Sales Variance by Product", | |
| "transform": [ | |
| { | |
| "calculate": "17000000", | |
| "as": "target" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //SPEC | |
| { | |
| "data": { | |
| "name": "dataset" | |
| }, | |
| "title": "Sales Variance by Product", | |
| "transform": [ | |
| { | |
| //"calculate": "datum['Total Sales'] *.80","as": "target" | |
| "calculate": "17000000", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //SPEC | |
| { | |
| "data": { | |
| "name": "dataset" | |
| }, | |
| "title": "Sales Variance by Product", | |
| "transform": [ | |
| { | |
| //"calculate": "datum['Total Sales'] *.80","as": "target" | |
| "calculate": "17000000", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "data": { | |
| "name": "dataset" | |
| }, | |
| "title":"Total Sales by Segment - Vertical Bar Chart", | |
| "encoding": { | |
| "x": { | |
| "field": "Segment", | |
| "type": "nominal", | |
| "sort":"-y", |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPECS | |
| { | |
| "data": { | |
| "name": "dataset" | |
| }, | |
| "title":"Sales Variance by Product", | |
| "transform": [ | |
| { | |
| //"calculate": "datum['Total Sales'] *.80","as": "target" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (t as table, seed as number) => | |
| let | |
| // Step 1: Add an index column to the input table to preserve row order and enable alignment | |
| Source = Table.AddIndexColumn(t, "__Index", 0, 1, Int64.Type), | |
| // Step 2: Generate a reproducible list of random numbers using the provided seed | |
| // This ensures consistent output across refreshes or deployments | |
| Random_List = List.Random(Table.RowCount(t), seed), | |
| // Step 3: Convert the random list into a table and add an index column for joining |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (df as table, independent as text, dependent as text)=> | |
| let | |
| Source = | |
| R.Execute( | |
| "df <- dataset " & | |
| "#(lf)logit <- glm(" & dependent & " ~ " & independent & ", data = df, family = ""binomial"")" & | |
| "#(lf)df$Predicted <- predict(logit, newdata = df, type = ""response"")" & | |
| "#(lf)df$Prediction <- ifelse(df$Predicted > 0.5, 1, 0)" & | |
| "#(lf)df", [dataset=df]), | |
| Return = Source{[Name="df"]}[Value] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| (df as table, independent as text, dependent as text, family as text)=> | |
| let | |
| Source = | |
| R.Execute( | |
| "df <- dataset" & | |
| "#(lf)logit <- glm(" & dependent & " ~ " & independent & ", data = df, family = """ & family &""") " & | |
| "#(lf)summary_model <- summary(logit) " & | |
| "#(lf)coef_df <- as.data.frame(summary_model$coefficients) " & | |
| "#(lf)coef_df$Variable <- rownames(coef_df) " & | |
| "#(lf)coef_df <- coef_df[, c(""Variable"", ""Estimate"", ""Std. Error"", ""z value"", ""Pr(>|z|)"")] " & |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| let | |
| EWMA = Function.From( | |
| type function(alpha as number, values as list, index as number) as number, | |
| (params) => | |
| let | |
| alpha = params{0}, | |
| values = params{1}, | |
| index = params{2}, | |
| // Accumulate EWMA values up to the specified index | |
| resultList = List.Accumulate( |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Cpl = | |
| /* | |
| =============EXAMPLE DATASET=================== | |
| CallID Duration_Minutes Agent Date | |
| C1001 4.2 Agent_A 2024-01-15 | |
| C1002 3.5 Agent_B 2024-01-15 | |
| C1003 2.8 Agent_C 2024-01-15 | |
| C1004 4.6 Agent_A 2024-01-15 | |
| C1005 3.9 Agent_B 2024-01-16 | |
| C1006 3.2 Agent_C 2024-01-16 |