m language
4 TopicsCreate a mutable global variable in M language
Hi, community, I'm working on a custom connector that needs to authenticate before data representation is done, and to do this I don't want to hardcode the auth credentials in my source code. So, I declared a global list variable named config = {"a"}; and in the shared MyCustomConnector.Contents function, I'm doing a List.ReplaceValue on item "a" in the list above. shared MyCustomConnector.Contents = (BaseUrl as text, ClientId as text) => List.ReplaceValue(config, "a", BaseUrl, Replacer.ReplaceText); so in my StartLogin function, I can just call the config by index like this. //Start Login StartLogin = (resourceUrl, state, display) => let AuthorizeUrl ="https://"&Text.From(config{0})&"/oauth/authorize?" & Uri.BuildQueryString( [ client_id = "11", response_type="code", state = state, redirect_uri = redirect_uri ] ) in [ LoginUri = AuthorizeUrl, CallbackUri = redirect_uri, WindowHeight = windowHeight, WindowWidth = windowWidth, Context = null ]; But it appears that, the List.ReplaceValue is not being executed because whenever I try to set credential for authentication, "a" is being passed into the URL. Any help will be much appreciated950Views0likes1CommentM language create '445' date table where first day of the year is Monday & Periods of 4 or 5 weeks
Hi, I need to create a date table with the 445 principe in query editor. The first day of the year is the first Monday of the year. One year includes 12 Periods and 4 Quarters. In every quarter you have 3 periods according to the 445 principe. 1st period and 2nd period include 4 full weeks. 3th period 5 full weeks. See the below image with an example for the year 2022. I need in my date table a column Week of Year and Period of Year. In 2022 to first Monday is 3 jan. Week 1 of the year is from 3jan till 9jan. Week 2 is from 10jan till 16jan. Period 1 starts 3jan till 30jan. Period 2 is from 31jan till 27 february. Example 2022 Anyone an idea on how to write this in M language? Thank you!Solved988Views0likes2CommentsCan you accomplish this in PowerBI:
I'm not certain this is even possible, or within the realms of PowerBI; but I know this is the right place to ask! I have a stock movements table that looks like this: It has various types of stock movements from Stocktakes, through to Deliveries and Sales, Etc..... Every Stock Movement creates a stock line, and the running total is written to the line at that time. Our users would like to select a specific Date / Time, and have the system return the total value of stock on hand based on their input. I have deduced that the following logic would give the correct result: A User to define Date on which they would like the Total Stock on Hand results returned Set the User Defined Date as the "End Date" Using a given input date, return the closest Stocktake date prior to the date Set the closest stocktake date prior to that date as the "Start Date" Return a sumarised Table showing the most recent Movement Records for each distinct Item Between the User Defined Date (End Date), and the Stocktake Date (Start Date) Result to deliver a table including Item, Running Totals & Value. Based on the above, and a user input parameter of: 09/03/2021 22:00; I would expect the resultant table to look like this:: I'm fairly new to PowerBI, so have a few questions: Can PowerBI accomplish this? (Returning / Filtering a Table from a user input Paramter) How would you do this in the PowerBI UX? Is this a DAX or a M Query type question? Any hints as to how I might accomplish this would be greatly welcomed!!! Regards Robbie785Views0likes1CommentUsing switch in M
Hi all, I have an easy problem, but as I am a beginner i M I have a bit proglem with this. I have the following calculation in dax swithing between several dates. However, I need to make the same calculation in power query and what i have been trying is not working does not pull the dates correctly: I have following: Date = SWITCH( TRUE(); 'table1'[Real Finish]<> BLANK(); 'table1'[Real Finish]; 'table1'[Remaining Finish] <> BLANK(); 'table1'[Remaining Finish]; 'table1'[Actual Finish]<> BLANK(); 'table1'[Actual Finish]; 'table1'[Real Start]<> BLANK(); 'table1'[Real Start]; 'table1'[Remaining Start] <> BLANK(); 'table1'[Remaining Start]; 'table1'[Actual Start]) Can some of you help me with this? Thank you for your time, AnastasiaSolved42KViews0likes3Comments