Forum Discussion
DennisGaida
8 years agoFrequent Visitor
How to use custom function to fill another query (main_data & main_data_additial)?
I'm intrigued by the text analytics (https://docs.microsoft.com/en-us/azure/cognitive-services/text-analytics/tutorials/tutorial-power-bi-key-phrases) example. Problem is, it is expensive for a lot o...
Anonymous
8 years agoNot applicable
DennisGaida,
Could you please post the code in the Advanced Editor of your currect query here?
Regards,
Lydia
DennisGaida
8 years agoFrequent Visitor
let
Source = Json.Document(File.Contents("C:\data\message.json")),
messages = Source[messages],
#"Converted to Table" = Table.FromList(messages, Splitter.SplitByNothing(), null, null, ExtraValues.Error),
#"Expanded Column1" = Table.ExpandRecordColumn(#"Converted to Table", "Column1", {"timestamp", "content"}, { "Column1.timestamp", "Column1.content"}),
#"Filtered Rows" = Table.SelectRows(#"Expanded Column1", each [Column1.content] <> null),
#"Renamed Columns" = Table.RenameColumns(#"Filtered Rows",{{"Column1.content", "Content"}, {"Column1.timestamp", "Timestamp"}}),
#"Kept First Rows" = Table.FirstN(#"Renamed Columns",20),
#"Invoked Custom Function" = Table.AddColumn(#"Kept First Rows", "KeyPhrases", each AI_KeyPhrases([Content])),
#"Invoked Custom Function1" = Table.AddColumn(#"Invoked Custom Function", "Sentiment", each AI_Sentiment([Content])),
#"Changed Type" = Table.TransformColumnTypes(#"Invoked Custom Function1",{{"Sentiment", type number}, {"KeyPhrases", type text}, {"Timestamp", Int64.Type}, {"Content", type text}}),
#"Changed Type with Locale" = Table.TransformColumnTypes(#"Changed Type", {{"Sentiment", type number}}, "de-DE"),
#"Added Custom" = Table.AddColumn(#"Changed Type with Locale", "Sentiment100", each [Sentiment]*100),
#"Changed Type1" = Table.TransformColumnTypes(#"Added Custom",{{"Sentiment100", type number}})
in
#"Changed Type1"The queries for the Azure Cognitive Services functions are pretty much the same as in the article posted in the original message.