# Load package
library(powerbiR)
# Use data from the powerbiR package
data(dim_hour)
data(fact_visitors)
# Define dataset and its tables
table_list <- list(fact_visitors, dim_hour)
table_names <- c("visitors", "hour")
dataset_name <- c("Online Visitors")
# Define relations between tables
relation <- pbi_schema_relation_create(
from_table = "visitors",
from_column = "hour_key",
to_table = "hour"
)
# Define sorting behavior of columns in the hour table
sortlist = list(
table = c("hour"),
sort = c("hour"),
sort_by = c("hour_key")
)
# Hide hour_key in the hour and visitors tables
hidden <- list(
list(
table = c("hour"),
hidden = c("hour_key")
),
list(
table = c("visitors"),
hidden = c("hour_key", "visitor_id")
)
)
# Create schema
schema <- pbi_schema_create(
dt_list = table_list,
dataset_name = dataset_name,
table_name_list = table_names,
relations_list = list(relation),
sort_by_col = list(sortlist),
hidden_col = hidden
)
Run the code above in your browser using DataLab