Closed SharmaAntriksh closed 3 years ago
Hi, just to clarify: You want an option to add a space before brackets regardless of the expression? Or is it only for function calls?
And does it only include round brackets "(" or also square "[" and squirly "{" ?
I don't think this feature will be a lot of work. It would be nice if you could provide me with an example powerquery code and the current + desired result so I have a clear view what you are trying to get.
Hi, thanks for replying, I am used to writing a lot of DAX code and so here is how I try to write M code:
How I write:
How the formatter formats:
code:
let
Source = Sales[Order Date],
DistinctDates = List.Buffer(List.Distinct(Sales[Order Date])),
DateList =
let
ConstYear = 1,
MinDate = List.Min(DistinctDates),
MinYear = Date.Year(MinDate) - ConstYear,
MaxDate = List.Max(DistinctDates),
MaxYear = Date.Year(MaxDate) + ConstYear,
FirstDate = #date(MinYear, 1, 1),
LastDate = #date(MaxYear, 12, 31),
ListOfDate = {Number.From(FirstDate) .. Number.From(LastDate)},
ConvertToTable = Table.FromList(ListOfDate, Splitter.SplitByNothing()),
ChangeColumnName = Table.RenameColumns(ConvertToTable, {{"Column1", "Date"}}),
ChangeType = Table.TransformColumnTypes(ChangeColumnName, {{"Date", type date}})
in
ChangeType,
YearNumber = Table.AddColumn(DateList, "Calendar Year Number", each Date.Year([Date]), Int64.Type),
YearText = Table.AddColumn(YearNumber, "Calendar Year", each "CY " & Text.From([Calendar Year Number]), type text)
in
YearText
Thanks for the example code. I just came up with a solution to provide you with your desired result. I still need to test a little bit but maybe I can push it to the website tomorrow.
Thanks a lot for considering this and for creating the formatter!
I just deployed the feature. Based on your sample I excluded the braces of FieldSelectors ([field]
) and ItemAccessExpression (item{[ Field = "" ]}
) from the additional whitespaces. Let me know if that works for you.
There were some edge cases to consider. I reviewed my test bench and everything looks fine but there is still a chance that I missed something so have a look if any duplicate whitespaces before or after braces occur. If you encounter any issues please file a issue with me.
Thanks for the appreciation!
Wow! Yup, that alright, this is awesome, loving it, Thanks!
At the moment the formatter removes additional spaces before and after brackets but if you can implement a functionality that keeps the spaces then it would be great, just like Dax Formatter has options to add spaces before and after brackets