|
1 | 1 | # pbix
|
2 |
| -PowerBI Coder/Decoder |
| 2 | +PowerBI `.pbix` file coder/decoder |
| 3 | + |
| 4 | + |
| 5 | +# [Build] |
| 6 | + |
| 7 | +# CLI |
| 8 | +### Print a formula (M script) from DataMashup/Formulas |
| 9 | +~~~ shell |
| 10 | +12:55 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ ./result/bin/pbix print --path ../examples/PowerBI_File_PBIX/iris.pbix --formula Section1.m |
| 11 | +section Section1; |
| 12 | + |
| 13 | +shared iris = let |
| 14 | + Source = Csv.Document(File.Contents("\\VBOXSVR\Shared\PowerBI\iris.csv"),[Delimiter=",", Columns=5, Encoding=1252, QuoteStyle=QuoteStyle.None]), |
| 15 | + #"Promoted Headers" = Table.PromoteHeaders(Source, [PromoteAllScalars=true]), |
| 16 | + #"Changed Type" = Table.TransformColumnTypes(#"Promoted Headers",{{"sepal_length", type number}, {"sepal_width", type number}, {"petal_length", type number}, {"petal_width", type number}, {"species", type text}}) |
| 17 | +in |
| 18 | + #"Changed Type"; |
| 19 | +12:55 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ |
| 20 | +~~~ |
| 21 | + |
| 22 | +### Print the Haskell AST (Abstract Syntax Tree) of a formula |
| 23 | +~~~ shell |
| 24 | +12:56 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ ./result/bin/pbix print --path ../examples/PowerBI_File_PBIX/iris.pbix --formula Section1.m -x | head -c 400 |
| 25 | +SectionDocument (Section {_section_attributes = Nothing, _section_name = Just (RegularI "Section1"), _section_members = Just [SectionMember {_sectionMember_attributes = Nothing, _sectionMember_shared = True, _sectionMember_name = Reg |
| 26 | +ularI "iris", _sectionMember_expression = LetE (LetExpression {_letExpression_variableList = [Variable {_variable_name = RegularI "Source", _variable_expression = Logi |
| 27 | +12:57 barak@berkos:~/Development/atidot/language-powerquery/build |
| 28 | +~~~ |
| 29 | + |
| 30 | +### Print the AST as a JSON |
| 31 | +- ([iris dataset]) |
| 32 | +~~~ shell |
| 33 | +12:58 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ ./result/bin/pbix print --path ../examples/PowerBI_File_PBIX/iris.pbix --formula Section1.m -x -j | head -c 1000 |
| 34 | +{"tag":"SectionDocument","contents":{"_section_attributes":null,"_section_name":{"tag":"RegularI","contents":"Section1"},"_section_members":[{"_sectionMember_expression":{"tag":"LetE","contents":{"_letExpression_expression":{"tag":"L |
| 35 | +ogicalE","contents":{"tag":"And_OE","contents":{"tag":"Is_LAE","contents":{"tag":"As_IE","contents":{"tag":"EqualityAE","contents":{"tag":"RelationalEE","contents":{"tag":"AdditiveRE","contents":{"tag":"MultiplicativeAE","contents":{ |
| 36 | +"tag":"MetadataME","contents":{"_metadataExpression_second":null,"_metadataExpression_annotation":[],"_metadataExpression_first":{"tag":"UnaryType","contents":{"tag":"Primary_TE","contents":{"tag":"FieldAccessPE","contents":{"_implic |
| 37 | +itTargetProjection_annotation":[],"tag":"ImplicitTargetProjection","_implicitTargetProjection_identifier":{"tag":"QuotedI","contents":"#\"Changed Type\""}}}}}}}}}}}}}}},"_letExpression_variableList":[{"_variable_annotation":[],"_vari |
| 38 | +able_expression":{"tag":"LogicalE","contents":{"tag":"And_OE","conte |
| 39 | +12:58 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ |
| 40 | +~~~ |
| 41 | +
|
| 42 | +### Print all String Literals (using [jq]) |
| 43 | +~~~ shell |
| 44 | +12:25 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ ./result/bin/pbix print --path ../examples/PowerBI_File_PBIX/iris.pbix --formula Section1.m -x -j | jq -c 'paths as $path | select(getpath($path) == "String |
| 45 | +L") | getpath($path[:-1]) | .contents' |
| 46 | +"\"\\\\VBOXSVR\\Shared\\PowerBI\\iris.csv\"" |
| 47 | +"\",\"" |
| 48 | +"\"sepal_length\"" |
| 49 | +"\"sepal_width\"" |
| 50 | +"\"petal_length\"" |
| 51 | +"\"petal_width\"" |
| 52 | +"\"species\"" |
| 53 | +~~~ |
| 54 | +
|
| 55 | +### Print all Variables names (using [jq]) |
| 56 | +~~~ shell |
| 57 | +12:47 barak@berkos:~/Development/atidot/language-powerquery/build (master) $ ./result/bin/pbix print --path ../examples/PowerBI_File_PBIX/iris.pbix --formula Section1.m -x -j | jq 'paths as $path | select($path[-1] == "_variable_name") | getpath($path) | .contents' |
| 58 | +"Source" |
| 59 | +"#\"Promoted Headers\"" |
| 60 | +"#\"Changed Type\"" |
| 61 | +~~~ |
| 62 | + |
| 63 | +[jq]: https://stedolan.github.io/jq/ |
| 64 | +[Build]: https://github.com/Atidot/language-powerquery#Build |
| 65 | +[iris dataset]: https://www.kaggle.com/arshid/iris-flower-dataset |
0 commit comments