Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Nolock
Resident Rockstar
Resident Rockstar

Expression.Evaluate(_, #shared) in PowerBI Service

Hello,

I'm searching for an explanation of the following problem:

 

I'm developing a lot of PowerQuery queries and recently, I had to use Expression.Evaluate:

 

Expression.Evaluate("my expression using the internal function Text.Upper ", #shared)

It works in Power BI Desktop. When I publish my dataset to PBI Service (Premium) and let it refresh, the following error comes:

 

Shared.PNG

Does anybody have an idea why it doesn't work?

 

Actually, I have a workaround for my current case, but it is not a general solution:

Expression.Evaluate("my expression using the internal function Text.Upper ", [Text.Upper = Text.Upper])

EDIT: Or if you need a list of all Text.* function names in PowerQuery, you can create it manually in advanced and use it as a record for the new scope:

let
    Shared = #shared,
    TextFunctionNames = List.Select(Record.FieldNames(Shared), each Text.StartsWith(_, "Text.")),
    Result = List.Transform(TextFunctionNames, each _ & " = " & _ & ",")
in
    Result

Thank you very much for an explanation or a hint in advanced.

Best regards,

@Nolock 

 

2 ACCEPTED SOLUTIONS
v-frfei-msft
Community Support
Community Support

Hi @Nolock ,

 

There is an idea about that, Seemed that the function is not fully supported yet.

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/19683592-provide-full-support-for...

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

Meanwhile you can use this workaround, if you're using many functions in your expression: https://www.thebiccountant.com/2018/05/17/automatically-create-function-record-for-expression-evalua...

..I know it's a pain 😉

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

4 REPLIES 4
v-frfei-msft
Community Support
Community Support

Hi @Nolock ,

 

There is an idea about that, Seemed that the function is not fully supported yet.

https://ideas.powerbi.com/forums/265200-power-bi-ideas/suggestions/19683592-provide-full-support-for...

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

Thank you, @v-frfei-msft. I've voted for the idea.

Meanwhile you can use this workaround, if you're using many functions in your expression: https://www.thebiccountant.com/2018/05/17/automatically-create-function-record-for-expression-evalua...

..I know it's a pain 😉

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Nolock
Resident Rockstar
Resident Rockstar

Hi @ImkeF,

thank you.

In the end, I've solved this problem with creating a list of all Text functions. 

let
    Shared = #shared,
    TextFunctionNames = List.Select(Record.FieldNames(Shared), each Text.StartsWith(_, "Text.")),
    Result = List.Transform(TextFunctionNames, each _ & " = " & _ & ",")
in
    Result

The list is stored in a utility group, the load is disabled and I just copy all the values of the list into a record. This record, let's call it "All text functions scope", is then used like: Expression.Evaluate("my expression", #"All text functions scope").

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors
Top Kudoed Authors