How to convert this formula from excel to M language? - powerbi

I'm try convert the formula bellow to Power BI M language
=IF(AC4>TIMEVALUE("20:00:00");"After the deadline";"In the term")
I tried formula bellow but doesn't work, it return this error message "The name 'IF' wasn't recognized. Make sure it's spelled correctly.":
=IF(
TIMEVALUE([#"(Transf1-Coleta)"]) > TIMEVALUE("20:00:00"),
"After the deadline",
"In the term"
)
The column [#"(Transf1-Coleta)"] is the same value of column "AC" and "AD" is the value that want get

if you are using Measure, try this below code-
=IF(
TIMEVALUE(min(table_name[column_name])) > TIMEVALUE("20:00:00"),
"After the deadline",
"In the term"
)

In M
= Table.AddColumn(#PreviousStep, "Custom", each if DateTime.Time([Transf1-Coleta])>Time.FromText("20:00:00") then "After the Deadline" else"In the term")

Related

Google Sheet Array Formula Put blank

I have this formula
=ArrayFormula(IF(LEN(C$3:F$3), H4:L4+C4:F4/$C$1, ""))
How i can modify this array formula to return Blank like in I7?
try:
=BYROW(B34:F38, LAMBDA(x, INDEX(SPLIT(TEXTJOIN(" ", 1, x), " "),,1)))

Search another google spreadsheet's sheet for A1 Value of current sheet, return column A,B,C's value in rows where A1 Value is found

I'm trying to query a value located in A1 of a current google spreadsheet, on a sheet located on another spreadsheet and return the values in columns A, B & C for every row where A1's value is found.
I'm dizzy.
I tried this:
=query(importrange("https://docs.google.com/spreadsheets/d/XXXXXXXXXXXX/edit","Master Investor List!A11:AX"),"select A,B,C where R or U or X matches '"&A1&"',1)
but I get this error:
Error Unable to parse query string for Function QUERY parameter 2: PARSE_ERROR: Encountered " "R "" at line 1, column 20. Was expecting one of: "(" ... "(" ...
try:
=QUERY({IMPORTRANGE("url_here"; "Master Investor List!A11:AX")};
"select Col1,Col2,Col3
where Col18 matches '"&A1&"'
or Col21 matches '"&A1&"'
or Col24 matches '"&A1&"'"; 1)

proper IF statement issue causing parse error

I am searching for a formula to combine three things. To capture the value of Cell A into cell B. If it has has a number then it should capture that number. If the value of cell A1 is - then it should change to blank in cell B1 and if it has a blank cell in A1 Then it should be blank in B1.
I have tried the formula in google sheet with IF, And OR combining but it is giving an error.
=if(OR(A1="-"," "),(A1=" ", " "))
=if(And(A1="-"," "),(A1=" ", " "))
=IF(A1="-"," ",IF(A1="","",IF(A1=" "," ")))
The expected results are giving an error or it gives the answer as false.
You should take a look at IF documentation to understand it better, but the main thing here is to remember that IF is IF(logical_expression, value_if_true, value_if_false)
The best option here would be to go with player0 solution, because it covers up almost every case: =IF(ISNUMBER(A1), A1, )
But just to help you out on understanding what was wrong with your formulas, even though those solutions don't check if A1 is a number:
=if(OR(A1="-"," "),(A1=" ", " "))
The correct way would be: =if( OR(A1="-",A1=" "), " ", A1)
=if(And(A1="-"," "),(A1=" ", " "))
This one is actually conceptually wrong, because you want to check if A1 = "-" AND A1 =" ", which is impossible and will never be true, because a cell can't be equal to "-" and " " at the same time.
=IF(A1="-"," ",IF(A1="","",IF(A1=" "," ")))
The correct way would be: =IF(A1="-"," ",IF(A1="","",IF(A1=" "," ",A1)))
that is not how you should use IF function.
If the value of cell A1 is - then it should change to blank in cell B1 and if it has blank cell in A1 Then it should be blank in B1
which could be solved like this in B1 cell:
=IF(ISNUMBER(A1), A1, )
and arrayformula of that would be:
=ARRAYFORMULA(IF(ISNUMBER(A1:A*1), A1:A, ))

Counting words in ARRAYS with ARRAYFORMULA in Google Sheets

Counting words with Array formula for every cell won't work.
I have tried to use:
=ARRAYFORMULA(COUNTA(SPLIT(Range, " ")))
=ARRAYFORMULA(SUM(COUNTA(SPLIT(Range," "))))
Both didn't work.
I expected ARRAYFORMULA to count words for every cell in the column and put it next to it, but it counted all the text and put it in one cell instead.
Copy of the sheet (Problem in Cell D123): https://docs.google.com/spreadsheets/d/1pPbJ9k4tiLk8hVxHXRgvu6b4vxJOcgTmyFhD_g8gc_Q/edit?usp=sharing
=ARRAYFORMULA(IF(LEN(A3:A),
MMULT(IF(IFERROR(SPLIT(IF(LEN(A3:A), A3:A, ), " "))<>"", 1, 0),
ROW(INDIRECT("A1:A"&COUNTA(IFERROR(
QUERY(IF(IFERROR(SPLIT(IF(LEN(A3:A), A3:A, ), " "))<>"", 1, 0), "limit 1", 0)))))^0), ))
also could be done by just counting the spaces:
=ARRAYFORMULA(IF(LEN(A3:A), LEN(REGEXREPLACE(A3:A, "[^\s]", ))+1, ))

Jasper Report If Else Condition Expression

I would like to ask about the if else expression in ireport jasper report. May I know is it possible to have multiple or more parameter in the if else statement?
(($P{endDate}.isEmpty()==true || $P{endDate}.equals(""))? "" :
" createDate>='" + $P{startDate} +"'" && " createDate<='" + $P{endDate} +"'")
Based on the code above, there are not allowed me to use "&&". It prompt out syntax error.
Besides that, May I know any solution to solve it? Thank you very much.
I'm assuming it's a query expression your trying to write. You probably would have to do something as follows:
Create a parameter for your dataset. This parameter should not be "prompted" and lets call it DATE_LIMIT_EXPRESSION. You should then set its default value as your expression. For example (if I a get what you meant), this could be your default expression:
"1" +
(($P{startDate}.isEmpty() == false) ? (" AND createDate >= " + $P{startDate}) : "") +
(($P{stopDate}.isEmpty() == false) ? (" AND stopDate <= " + $P{stopDate}) : "")
Now, your dataset query should be something like:
select
...
where $P!{DATE_LIMIT_EXPRESSION}
Just notice the "$P!" syntax. You can find more information about this in the Jasper Reports' documentation.