Search code examples
powerbipowerquerym

Can I transform a table with 1 value into a text format in power BI?


I am using R.execute in Power BI to find the username of the current user to a computer. (our organisation works with sharepoint). this way I want to make a universally true filepath for any user. This M code is in a table that is standing on it's own. I want to form this table into a text format instead of a table so I can use it as a text variable for the filepath.

M code to find username:

let
        RScript = R.Execute("output <- read.table(text=system2(""whoami"", stdout=TRUE))"),
        output = RScript{[Name="output"]}[Value]
in
        output

Now, this creates a table with only 1 value. Any way I can transform this into a simple text value? Or perhaps select this single value to perform as a variable for my filepath??

Thanks for the help!


Solution

  • Just specify row number and column name:

    output = RScript{[Name="output"]}[Value]{0}[Column1]
    

    Or, assuming, column name may be changed:

    output = Record.FieldValues(RScript{[Name="output"]}[Value]{0}){0}