Search code examples
powerbipowerquerym

How can I transform a table with only ONE cell into a simple value?


For example: if I just have this table

---------
| power |
---------
| 100   |
---------

I just want the value 100 (a number in this case). And if for example, the value is a string I want to have the value of the string too.

I need this to incorporate this subquery into another query, more precisely in a condition function.

PS: I use M language (Power Query in POWER BI Desktop)


Solution

  • After you load the table in the query editor, you can right-click on the value 100 and select Drill Down. This will give you a single value instead of a table.

    It does this using the M code Source{0}[Power] where 0 is the row index and Power is the column.

    let
        Source = <data source for your table>,
        Power = Source{0}[Power]
    in
        Power
    

    There are other ways you can do this too. For example, the first element in the table's column:

    List.First(Source[Power])