Forum Discussion

Nerdio's avatar
Nerdio
New Member
7 months ago
Solved

Creating constants

I am new to using Power BI and I am just dabbling with the functionality to see what can be done. The application I have in mind will have a lot of calculations where a constant value is used. Rather...
  • danextian's avatar
    7 months ago

    Hi Nerdio 

    A measure can actually accept a constant value and can be referenced in other calculations. Example

    Constant Value - Number = 100
    
    Constant Value - Text = "100"
  • Thejeswar's avatar
    Thejeswar
    7 months ago

    Hi Nerdio ,

    Yes you can create a constant table directly in Power BI without importing data from an external location using the DATATABLE() DAX function as a calculated table

    For example, the below code would create a table called Sizes with two columns Name and Ordinal holding the values mentioned under them

    Sizes =
    DATATABLE (
    "Name", STRING,
    "Ordinal", INTEGER,
    {
    { "Small", 1 },
    { "Medium", 2 },
    { "Large", 3 }
    }
    )

     

     Regards,