I am using the function DayOfWeekAsString in my script which returns the complete day name.
I am looking for some function which delivers the day name like "SA, SU, MO, TU,..."
Is there a predefined function available?
There is nothing built in to do that but this should do it:
uCase( left( dayOfWeekAsString( 1 ), 2 ) )
Related
I'm quite new in using DAX in PowerBi and I need to perform the following dax function:
Latest Detailed =
LOOKUPVALUE (
EXAM_REPORT[ACTUAL_EXAM_DATE],
EXAM_REPORT[CES EXAM.EXAM_TYPE_SR_KEY],
EXAM_REPORT[CES EXAM.EXAM_TYPE_SR_KEY] = 2,
EXAM_REPORT[CES EXAM.EXAM_SIGNOFF_DATE],
ISBLANK ( EXAM_REPORT[CES EXAM.EXAM_SIGNOFF_DATE] ) = FALSE,
EXAM_REPORT[ASSET_GUID],
[ASSET_GUID] = [ASSET_GUID]
)
Unfortunately I keep getting this error:
Function 'LOOKUPVALUE' does not support comparing values of type Number with values of type True/False. Consider using the VALUE or FORMAT function to convert one of the values.
I’ve tried converting everything to strings and also tried VALUE as well, but nothing changes.
Could you please help me? How can I do in a way that all the values share the same datatype?
LOOKUPVALUE has a different signature than what you are using:
LOOKUPVALUE(
<result_columnName>,
<search_columnName>,
<search_value>
[, <search2_columnName>, <search2_value>]…
[, <alternateResult>]
)
Your Code:
LOOKUPVALUE(
<result_columnName>,
<search_columnName>,
<search_columnName> = <search_value>
)
And FALSE must be FALSE(), but the condition is inappropriate anyway.
The function searches a value in a Excel workbook and gives me a cetain info.
It Works like this:
Excel
Column1 Column2
A 1
B 2
C 3
My Function ("A") - Output > 1
My Function ("B") - Output > 2
My Function ("C") - Output > 3
Now i got a table in Power Query, like this:
Power Query
ColumnX
B
C
A
A
I want to create another column on the power query table using my function. And as input i want to use de column X.
But right now, it isn't working.
PS. the output of the function is a M Formula(Ex:. [Column10] * [Column11])
The line of code that i'm using is:
= Table.AddColumn(#"Tipo Alterado", "Formula", each Expression.Evaluate(MyFunction([ColumnX]),#shared))
Already tried without de enviroment variable and it didn't work.
PS2: If i write the code as if it was only one input at columnX it works!
The code looks like this:
= Table.AddColumn(#"table1", "Formula", Expression.Evaluate(MyFunction("B"),#shared))
Someone knows how to make it work ?
Updated
You can remove all of the Expression Evaluate calls. (The second step looks like you're passing the result of a function, but Table.AddColumn needs a function definition )
PS. the output of the function is a M Formula(Ex:. [Column10] * [Column11])
In that case you may want to pass the row as the argument, instead of the specific column. It depends on what you're doing.
let
Source = ...,
MyFunction = (row as record) =>
row[Column10] * row[Column11],
#"Add Column2" = Table.AddColumn(
Source, "Column2",
(row) => MyFunction( row ),
type any // replace with the right type
)
in
#"Add Column2"
Original Answer
I think what you're asking for is a simple mapping. You can skip the Expression.Evaluate
= Table.AddColumn(
Source, "Column2",
(row) =>
MyFunction( row[Column1] ),
type any
)
I would like to run a couple of similar command sequences from a menu in Lauterbach T32 (or even from the toolbar, the issue is the same).
Menu is built using something like:
menu.reprogram
(
add toolbar
(
toolitem "Say NE", "SN,r"
(
GOSUB sayNE
)
)
)
enddo
sayNE:
(
print "ne"
return
)
According to documentation, this is supposed to work. Something similar works if I remove the menu.reprogram part and only run "gosub sayNE".
But when this code is supposed from the actual menu callback, it does NOT. It prints "no such label" error message which is not really helpful.
I have even trying moving the subroutine into an included file, which is sourced in via Do ~~~~/subSayNE.cmm followed by gosub .... The Do ... command works but calling gosub afterwards brings the same "no such label" error as before.
It looks like there is a restriction on what's allowed to do but I cannot find it documented. Is there any way to use subroutines there or is there any better trick to run repeated actions with only minor modifications (parameters)?
The subroutines are only available during the time the script is executed. When script execution ends (in your case this happends with the ENDDO command), the labels/subroutines cease to exist.
A good solution for this problem is to equip the script with a calling parameter. When the script is called without parameter, the menu or toolbar is installed. If the script is called with a parameter, then the subroutine with the same name is called.
The user will install the menu/toolbar by calling the script without parametes, while the menu/toolbar item will call the script with the subroutine name as parameter.
PRIVATE ¶meter
ENTRY %LINE ¶meter
IF "¶meter"!=""
(
;if parameter specified, go to subroutine with that name
GOSUB ¶meter
ENDDO
)
ELSE
(
;set up script caller
PRIVATE &CALL
&CALL="DO """+OS.PresentPracticeFile()+""" "
; "&+" in the menu means that macro &CALL will be replaced at compile time
MENU.ReProgram
(&+
ADD
TOOLBAR
(
TOOLITEM "Say NE" "SN,r"
(
;call script with parameter SayNe
&CALL SayNe
)
)
)
ENDDO
)
;subroutines
SayNe:
(
PRINT "ne"
RETURN
)
i'm trying to figure out, how I can get my formula working.
It's telling me I need a valid date.
So if i'm going for this :
J3=checkbox, D5=date formated with =today(), G5=number between 1-30
=WENN(J3=FALSE;D5+G5)
This works fine ( today() + 1-30 )
Now here comes the error :
=WENN(J3=FALSE;D5+G5;);WENN(J3=TRUE;D5+7;)
This does not work because now it's telling me I need the valid date.
So my question is, how I can get it work?
try like this:
=IF(D3=FALSE; A3+C3; A3+7)
for arrayformula use:
=ARRAYFORMULA(IF(A3:A="";;IF(D3:D=FALSE; A3:A+C3:C; A3:A+7))
I'm new to PowerBi and i'm running into the following problem:
Weeknum + year are not shown in the correct order. See the following screenshots:
I've concatenate weeknumber with year based on a column called "PublishDate"
This is my dax query for weeknum:
Weeknum = YEAR ( [PublishDate] ) & "" & WEEKNUM ( [PublishDate], 2 )
I do notice that 1 till 9 are not shown with a 0 infront of it. Could this be causing this?
I agree with getting the '0' in the right place. Once you change the data type from text to a number, if that '0' in't there, it will be out of order as well.
I prefer editing the query and changing the data type from the beginning:
Finding the column that needs a data type change and modifying it there:
[
You can change it from text to whole number.
The problem is that the values are being sorted in alphabetical order, because they are of datatype text. So yes, the fact that '9' does not have a '0' in front of it, does cause your problem. You can solve this by changing the format of the WEEKNUM function like this (also you do not need & "" &):
Weeknum = YEAR ( [PublishDate] ) & FORMAT(WEEKNUM ( [PublishDate], 2 ),"00")