Back to all posts

How to Create table in Power BI using Dax

ROW: The ROW function in DAX creates a single row table with the specified columns and values. ROW(columnName1, value1, [columnName2, value2], ...) Si…

ROW:

The ROW function in DAX creates a single row table with the specified columns and values.

SQL
ROW(columnName1, value1, [columnName2, value2], ...)

SingleRowTable = ROW("ID", 1, "Name", "Aman")

SalesInfo = 
ROW(
    "Total Sales", SUM(Sales[Amount]),
    "Max Sales", MAX(Sales[Amount])
)

DATATABLE:

DATATABLE function allows you to create a table with data directly in a DAX expression.

Bash
CategoryBudget = 
DATATABLE(
    "Category", STRING,
    "Budget", INTEGER,
    {
        {"Electronics", 500},
        {"Furniture", 300},
        {"Clothing", 400}
    }
)

Bash
CategoryBudget = 
    {
        ("Electronics", 500),
        ("Furniture", 300),
        ("Clothing", 400)
    }

GENERATESERIES:

The GENERATESERIES function in DAX is used to create a table with a single column of a series of values. It is especially useful for generating sequences of numbers or dates, which can be used for various purposes in your data model, such as creating a time table or setting up bins for data categorization.

HTML
GENERATESERIES(<start_value>, <end_value>, &#091;<increment>])

--increment (optional): The increment value between each row in the series. The default is 1.
Plain Text
NumberSeries = GENERATESERIES(1, 10)


SQL
DateSeries = GENERATESERIES(
    DATE(2024, 1, 1),
    DATE(2024, 1, 10),
    1
)

Keep building your data skillset

Explore more SQL, Python, analytics, and engineering tutorials.