microsoft / power-fx Goto Github PK
View Code? Open in Web Editor NEWPower Fx low-code programming language
License: MIT License
Power Fx low-code programming language
License: MIT License
This implementation of the Concat
function doesn't accept the optional "Separator" argument specified in the documentation/that exists in Power Apps:
It looks like this is related to the general implementation of functions with optional arguments/multiple different sets of arguments, inspecting the implementation of some of the aggregate numerical functions like Average
:
So, perhaps this issue can be used to track improvements to the function dispatch implementation? (Would this be multiple dispatch?)
First of all, I'm a ProDeveloper and โค PowerApps and it's language.
Therefore I would like to have a notation for the Coalesce(...)
statement like:
value1 ?? value2 ?? value3 ?? ...
in addition to Coalesce(value1, value2, value3, ...)
This would be similar to the notation of condition1 || condition2
.
This is a list of error messages that should be made clearer:
ShowColumns is not yet implemented. it is a priority for my project, should that affect the roadmap.
Hello, I am experimenting with this library and encountered the following problem:
This is my code:
var expression = "LookUp(Settings, Name = \"Client\")";
var engine = new RecalcEngine();
var parameters = FormulaValue.RecordFromFields(
new NamedValue("Settings",
FormulaValue.TableFromRecords(
FormulaValue.RecordFromFields(new NamedValue("Name", FormulaValue.New("Client"))),
FormulaValue.RecordFromFields(new NamedValue("Name", FormulaValue.New("Test"))))));
var result = engine.Eval(expression, parameters);
I expect that this expression will be evaluated correctly and will return only the first table record (the name of which is exactly "Client"). But instead an exception is thrown. This is its message:
Errors: Error 0-33: Invocation of unknown or unsupported function.
Error 17-21: Name isn't valid. This identifier isn't recognized.
Error 22-23: Incompatible types for comparison. These types can't be compared: Error, Text.
I found that in your BuiltInFunctionsCore
file there are public static readonly
fields for each built-in function but the LookUp
and Search
are missing. Maybe this is one reason for this behavior?
LanguageServer ctor should take a logger callback object so that hosts can log exceptions callstacks coming from this try-catch:
LSP will catch and convert to a proper error message for the client, but the host may still need to get a notification and log a callstack to telemetry.
LSP is special here because it handles messages asynchronously. Whereas most others can throw an exception from their callstack and host will just catch it.
See if we can use https://docs.microsoft.com/en-us/dotnet/api/microsoft.extensions.logging.ilogger?view=dotnet-plat-ext-6.0
To make the language more powerful and useful tables should become multi dimensional.
Tests get all sorts of failures when run in machines that are set in a non en-us locale
DateDiff
examples from the official docs like this one fail:
DateDiff(Now(), DateValue("1/1/2014"), Months)
They only work if TimeUnit.
is prefixed to the unit, so this works fine:
DateDiff(Now(), DateValue("1/1/2014"), TimeUnit.Months)
Since the official docs are in the non-prefix format, should this be fixed in the parser?
I've been generally uninterested in the power platform since from what i understand, it's only available as a hosted product from microsoft, meaning that any apps written in it is locked in to online use/hosting with Microsoft. This is absolutely fine for some projects mind you, just not something that has been applicable to the things i'm working on
However from what i understand Powerfx will eventually be open source and available to any application. will it be hostable inside a .net app for example? What about language services, for statement completion and syntax highlighting, will that also be available? WIll a host application be able to get an AST (similar to roslyn for example) to analyze the Powerfx code?
I can see Powerfx as a useful tool to expose some high level query functionality in our internal apps,
Hi,
I'd like to parse the formula before executing it :
Use case:
A, B, C, D
, user choose to display A, B
SELECT A, B FROM MyTable
F = ThisItem.C & ThisItem.D
A, B, F
Here we need to parse formula F
to know we need to query C, D
from DB
=> SELECT A, B, C, D FROM MyTable
Is there any way to achieve this ?
Could we expose the formula parser to retrieve used fields ?
Thank you
IExternalOptionSet
used in a particular formula type value through DType
.DType
to FormulaType
in FormulaType.Build
, the code below is dropping the IExternalOptionSet
information, which effectively renders it unusable. // FormulaType.cs -> FormulaType.Build
case DKind.OptionSetValue:
{
bool? flag = type.OptionSetInfo?.IsBooleanValued;
if (!flag.HasValue || !flag.Value)
{
return OptionSetValue; // <---- IExternalOptionSet is not passed in here.
}
return Boolean;
}
The request here is to expose public IExternalOptionSet
information on the OptionSetValueType
. The minimum necessary to avoid using DType
in PVA is to expose the entity name as a string and propagate it in the above code.
Many of us build LOB no-code platforms. Can we have a sample showing how to integrate the open sourced libraries into our products, especially:
This libraries look awesome!
tl;dr: The team meanwhile update the README with a link to the samples
What are the requirements for using/working on PowerFx? Windows, or does it work on macOS?
Also, is this being continued, or was it just a PoC and paid, hosted PowerApps is taking over as how PowerFx will move forward?
Hello,
I'm very existed about this project! Thank you!
I'm wondering if this the only language spec is open sourced or an entire platform? To re-phrase it will be possible to use Power-Fx in self-hosted apps which doesn't use Power Platform at all?
DAX is another Excel-like Language of MSFT, used in Power BI.
How do these two Languages relate to each other? Please document this
Maybe a list of all Power-Platform / BI Languages and their scope would be helpful as well.
only numerical valued custom functions with numrerical arguments are supported. adding strings and bools would be great for starters.
many thanks for the important work being done here!
This test case fails, as well as a bunch of others:
true <> false
true
The interpret hangs on this expression:
Mid(Text(1/0, "#.000"), 1)
Looks like hangs is in here:
private static IEnumerable<FormulaValue> MidFunctionExpandArgs(IRContext irContext, IEnumerable<FormulaValue> args)
{
var res = new List<FormulaValue>(args);
while (res.Count < 3)
{
// The third argument to Mid can only ever be used if the first argument is a string
if (args.First() is StringValue stringValue) <-- arg is ErrorValue, so we loop forever.
{
var count = new NumberValue(IRContext.NotInSource(FormulaType.Number), stringValue.Value.Length);
res.Add(count);
}
}
return res.ToArray();
}
We need a build of PowerFx that supports two parameters to PowerFxConfig (EnumStore and CultureInfo) AND be able to get the FormulaType for OptionSet.
When I try to get the source span(in-order to get a string representation) for a lambda (Eg: a > b in CountIf(TestTable, a > b)
, The source context for the lambda is 0-Length of formula. Is this by design?
In file IRTranslator.cs (Line 271):
args.Add(new LazyEvalNode(context.GetIRContext(node), child));
The IRContext of the current node is passed in instead of the current arg ( var arg = node.Args.Children[i];
). Passing in arg gives the corrext source span.
The images in the documentation don't have descriptive alternative text. For example, in the overview document, what I believe screenshots are provided. The images were text is writen and where that text is meaningful should have the alt attribute set to that text rather than a generic description, or the image should be substituted by the text. I haven't looked much in the documentation, but maybe there are images where information which is not text is not correctly conveyed for a blind user through the alt attribute.
(The alt attribute is set between the exclamation point and the closing square bracket)
I have the following expression:
Concatenate("Hello", " World!")
However, as simple as it looks I do not get the expected result. This is the exception I am encountering:
System.InvalidOperationException: Errors: Error 19-20: Unexpected characters. The formula contains 'ParenClose' where 'Error' is expected.
Error 19-20: Unexpected characters. Characters are used in the formula in an unexpected way.
at Microsoft.PowerFx.Core.Public.CheckResult.ThrowOnErrors()
at Microsoft.PowerFx.RecalcEngine.Eval(String expressionText, RecordValue parameters)
...
And my code is nothing special:
var defaultCulture = CultureInfo.CreateSpecificCulture("en");
var engine = new RecalcEngine(defaultCulture);
var result = engine.Eval(formula, contextRecord);
I would appreciate your help!
In the same way that RecordValue has a virtual GetField, it would be nice if RecordType had some virtuals.
The documentation does not contain any information on operator precedence. Are all operators the same precedence?
Excel has upto 3D array formulas. Power Fx also should have the notion of an n-D array which can contain a mix of other variables, arrays or array slices and tables or table slices.
Some functional languages with immutable data support an optimization where a function calls with identical arguments will only be called once and the return value is cached.
Is that currently a feature of Power-fx? Or is it planned?
You say Power-Fx is based on the formulas in Excel and that makes me worried since the formulas in Excel can't even handle very basic tasks. Also Excel formulas don't work very well outside US when it comes to how they handle regional and localized data formats.
Power Automation is so bad and unproductive to work with today, that it goes faster to set up a webserver and just write C# code to do whatever it is you need doing.
The reason for this is the lack of some of the most basic things you need when dealing with data, just try to parse a date/time from a string, or manipulate a file path.
Awesome job!
Will Power-Fx support asynchronous functions?
Currently Calculated Columns only offer a very small subset of the functions available to canvas apps. Ideally they would support the full array of functions available, but in this issue I can only give the concrete example I've run into:
Problem: Calculate the number of days from today to some date, called StartDate
Formula listed in MSDN: DiffDays(StartDate, NOW())
Error: NOW()
returns a DateTime, while StartDate
returns a Date, DiffDays is unable to resolve these different types
Possible solutions, using Power FX formulas:
TODAY()
method instead of NOW()
so both data types are DatesStartDate
NOW()
Note: None of the methods mentioned above are currently available in calculated columns
These expressions should return a table with 5 elements. Today they don't (the first one does not work, the second one removes the empty record):
I wrote a whole rant on some things that I didn't like in Power Apps in dev.to. But I'll try to keep it civil here.
https://github.com/microsoft/Power-Fx/blob/main/docs/global.md#formula-separators-and-chaining-operator this makes no sense.
1 - It fools seasoned programmers and our conventions
2 - it fools newcomers in thinking that ye old copy/paste from the internet solution will work for them, making forums less useful and friendly
3 - Its not "Think Excel". Excel lets you change separators independent of where you are in the world.
4 - In some regions, it just makes the code look ugly (eg.: ;;
)
5 - Documentation in docs.microsoft.com is not localized (yet). This creates confusion.
One solution is to get rid of this localization system all together and follow a nice standard.
The other is to see follow item 3 and just let developers choose what format to use.
Is there any chance to connect, - even in the future, my power apps to my firebase datas?
The overview for Power-Fx states:
Power Fx will be made available as open-source software. It's currently integrated into canvas apps, where you can experience it today. We're in the process of extracting it from Power Apps for use in other Microsoft Power Platform products and as open source. More information: Microsoft Power Fx on GitHub
https://docs.microsoft.com/en-us/power-platform/power-fx/overview
I have questions
I note F# and VSC are MIT-licenced and TypeScript is Apache2
What i can only see , it is just some document.
But as programming language. said open source, Where is the source code.
Or why you called it Open Source.
Am i wrong to understand what is the opensource.
Hey , I am happy to open source Power-FX (But only the document open source)
How did you feel like it ?
At the risk of embarrassing myself publicly, I'd like to wonder if the currency
type should be a floating point number. It should use an integer or decimal type, right?
This is described in the preview documentation here: https://github.com/microsoft/Power-Fx/blob/main/docs/data-types.md
I've read (e.g. http://blog.plataformatec.com.br/2014/09/floating-point-and-currency/) that using float point numbers for currency values can cause errors.
When using the Power Fx formula to set the visibility of a Command (in the new Command Bar editor), I realized that a newly added option in the Choice did not show up in Formula bar. Even after I have published all the customization. The option is visible in the Custom Page formula bar. Please see the attached screenshot below.
I'm not sure if this is the place for this, but I don't know where else to put it!
I've been a fan of Moment.js for years. It's a library that you can use for various date calculations/formatting in different languages. Now, Power Fx handles calculations & formatting pretty well. There's only one thing missing to me: relative dates. I would love Power Fx to have that as well (without a lot of formula usage...).
I would love to see some formula or extra formula where we can input a date and then it will calculate how long that's from the current date: 1 hour ago, 2 days ago, in 2 days, in 2 hours, etc.
Is this an option for Power Fx?
Error message is coming from here:
Power-Fx/src/strings/en-US/PowerFxResources.resw
Line 1632 in bfb78ea
This is similar to a6b42af
When I try to run the notebook in Dev Containers or Codespaces, I get the exception below.
Error: System.TypeInitializationException: The type initializer for 'Microsoft.PowerFx.Core.Texl.BuiltinFunctionsCore' threw an exception.
---> System.TypeInitializationException: The type initializer for 'Microsoft.PowerFx.Core.Types.Enums.EnumStore' threw an exception.
---> System.ArgumentException: currentLocale
at Microsoft.PowerFx.Core.Utils.Contracts.CheckNonEmpty(String s, String paramName)
at Microsoft.PowerFx.Core.Localization.StringResources.TryGet(String resourceKey, String& resourceValue, String locale)
at Microsoft.PowerFx.Core.Localization.StringResources.Get(String resourceKey, String locale)
at Microsoft.PowerFx.Core.Utils.LanguageConstants.get_SortOrderEnumString()
at Microsoft.PowerFx.Core.Types.Enums.EnumStore..cctor()
--- End of inner exception stack trace ---
at Microsoft.PowerFx.Core.Types.Enums.EnumStore.get_EnumSpec()
at Microsoft.PowerFx.Core.Types.Enums.EnumStore.TryGetEnumSpec(String name, String& dType)
at Microsoft.PowerFx.Core.Types.Enums.EnumStore.GetEnum(String name)
at Microsoft.PowerFx.Core.Types.ErrorType.get_ReifiedErrorSchema()
at Microsoft.PowerFx.Core.Types.ErrorType.ReifiedError()
at Microsoft.PowerFx.Core.Texl.Builtins.IfErrorFunction..ctor()
at Microsoft.PowerFx.Core.Texl.BuiltinFunctionsCore..cctor()
--- End of inner exception stack trace ---
at Microsoft.PowerFx.Core.Texl.BuiltinFunctionsCore.get_BuiltinFunctionsLibrary()
at Microsoft.PowerFx.Core.Glue.SimpleResolver..ctor(TexlFunction[] extraFunctions)
at Microsoft.PowerFx.Core.Glue.SimpleResolver..ctor(IEnumerable`1 enumSymbols, TexlFunction[] extraFunctions)
at Microsoft.PowerFx.RecalcEngineResolver..ctor(RecalcEngine parent, RecordType parameters, IEnumerable`1 enumSymbols, TexlFunction[] extraFunctions)
at Microsoft.PowerFx.RecalcEngine.CheckInternal(String expressionText, FormulaType parameterType, Boolean intellisense)
at Microsoft.PowerFx.RecalcEngine.Check(String expressionText, FormulaType parameterType)
at Microsoft.PowerFx.RecalcEngine.Eval(String expressionText, RecordValue parameters)
at PowerFxDotnetInteractive.PowerFxExpression.EvaluateSingleExpression(String originalExpression, String expression)
at PowerFxDotnetInteractive.PowerFxExpression.Evaluate()
at PowerFxDotnetInteractive.PowerFxKernel.HandleAsync(SubmitCode code, KernelInvocationContext context)
at Microsoft.DotNet.Interactive.Kernel.HandleAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\Kernel.cs:line 257
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<BuildPipeline>b__6_0(KernelCommand command, KernelInvocationContext context, KernelPipelineContinuation _) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 57
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<>c__DisplayClass6_1.<<BuildPipeline>b__3>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 73
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.CompositeKernel.LoadExtensions(KernelCommand command, KernelInvocationContext context, KernelPipelineContinuation next) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\CompositeKernel.cs:line 144
at Microsoft.DotNet.Interactive.KernelCommandPipeline.<>c__DisplayClass6_0.<<BuildPipeline>g__Combine|2>d.MoveNext() in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 74
--- End of stack trace from previous location ---
at Microsoft.DotNet.Interactive.KernelCommandPipeline.SendAsync(KernelCommand command, KernelInvocationContext context) in D:\a\_work\1\s\src\Microsoft.DotNet.Interactive\KernelCommandPipeline.cs:line 48
It seems to be something to do with Culture. I tried to set DOTNET_SYSTEM_GLOBALIZATION_INVARIANT
to false and also install libicu-dev
(as per https://andrewlock.net/dotnet-core-docker-and-cultures-solving-culture-issues-porting-a-net-core-app-from-windows-to-linux/), but it doesn't seem to fix it.
My Dev Container config is in https://github.com/rajyraman/Power-Fx-.NET-Interactive
This should allow us to eliminate SelfNode and ParentNode, which are reserved identifiers for Canvas, but don't apply to all hosts.
I may have missed something, but there doesn't appear to be a way to get a list of all defined formulas/variables back from the RecalcEngine. I see that the value can be retrieved if you have the name, but this would require the PowerFx-consuming application to remember the names of all formulas/variables.
I believe this would be useful for many reasons, but the two initial use cases I've come across that couldn't be addressed due to this missing are:
When I try to use LanguageServer, I am getting -32602 (InvalidParams) error. So, I would like to Debug using Source Link. When I step through to Power Fx code, I get the error below.
Please update the Source Link information for the assemblies published on Nuget. If I ignore the warning and use the LanguageServer file on my local machine, the debug is all messed up and I am unable to step through properly.
Several function names are repeated twice on the help message output of Help(), such as Max, Sum and Average
Hi
We currently need to do some async stuff to populate a RecalcEngineScope
So when using the IPowerFxScopeFactory
we need to re-synchronise task to respect GetOrCreateInstance
method.
It would be nice to have a GetOrCreateInstanceAsync
method, to avoid sync over async
Thank you
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.