My problem is that I can't get the IF condition to work in powerpivot (using DAX).
According to manual the syntax is:
IF(logical_test>,, value_if_false) where I can omitt the "value if false" if i want.
I have a lot of columns and I try to make a new one based on condition from another column.
What I tried is =IF([TimeTypeCode]="400", [WorkingHours]) and that doesn't work. What I want my condition to do is that if [TimeType] is equal to 400, then i want to put the value from [WorkingHours] in my new column. How can i do this?
from what I see here the problem is the ="400", the "" you used tell dax thats a string type and you are trying to use it as a numeric value.
Try using
IF([TimeTypeCode]=400, [WorkingHours])
instead,
Cheers!
Related
I have been struggling to return the count of courses from this XML file that contain "Cross-listed" as their description. The problem I encounter is because I am using for, it iterates and gives me "1 1" instead of "2". When I try using let instead I get 13 which means it counts all without condition even when I point return count($c["Cross-listed"]. What am I doing wrong and how can I fix it? Thanks in advance
for $c in doc("courses.xml")//Department/Course
where some $desc in $c/Description
satisfies contains($desc, "Cross-listed")
return count($c)
The problem I encounter is because I am using for
You are quite correct. You don't need to process items individually in order to count them.
You've made things much too difficult. You want
count(doc("courses.xml")//Department/Course[Description[contains(., "Cross-listed"]])
The key thing here is: you want a count, so call the count() function, and give it an argument which selects the set of things you want to include in the count.
How to use =SWITCH & IIF condition to change color in SSRS if the condition is met. I have two columns “ScheduledDate” (which is date/time), and Activity(which is text format). I want to change the color of Activity (which has the output as Complete, Current, Overdue), if the ScheduledDate is greater than today’s date, then I want to change the Overdue data in Column Activity to RED.
Should using Switch would be good or IIF. How? Can anyone please give an example?
Appreciate any help on this one.
Thanks,
Niki
In this scenario, if you only need set RED without setting multiple color for fields, it's better to use IIF(). Base on your condition, try the expression below:
=IIF(Fields!ScheduleDate.Value>Now() and Fields!Activity.Value="Overdue",Red,Black)
I think I figured it out. It works. Thanks for your help.
=iif(Fields!ScheduleDate.Value > Now() and Fields!Activity.Value ="Cancelled","Red",
iif(Fields!ScheduleDate.Value < Now() and Fields!Activity.Value ="Created","Green","Red"))
I entered the below formula into excel. When I copy the formula down for the rest of my sheet, it gives the "eligible" value to all fields even when the J field has no data to pull from. What am I missing?
=IF(J3<=40,"Eligible",IF(AND(J3<=30, J3>=39.99), "Particially","No"))
Blank is interpreted as zero, so J<=40 will be true. You probably need to put an IsNumber check in there too.
=IF(AND(J3<=40,ISNUMBER(J3)),"Eligible",....
EDIT: based on your comment, you can simplify this by reversing the logic, and you don't need an and clause.
=IF(J1<30,"no",IF(J1<40,"partial","eligible"))
I think logic is wrong.
Try this (included remark by John Barça):
=IF(ISNUMBER(J3),IF(J3<30,"Eligible",IF(AND(3<=39.99,J3=30),"Partially","no")),"Not a number")
Or please describe what you want to get.
Can someone help me determine which I should be using?
Here is the situation - I am pulling a value from a column in the Data Table. If there is anything in that column, I set the data to a variable and take an action. If the column is blank, I want to skip that.
I am confused as to which IsWHATEVER statement would be best. For Example:
If IsEmpty(Datatable.Value("M4","Data_Entry"))=False Then
OR
If IsNull(Datatable.Value("M4","Data_Entry"))=False Then
OR
If IsNothing(Datatable.Value("M4","Data_Entry"))=False Then
Suggestions?
I've just tried all of your options and found this to be the most correct:
If (DataTable.Value("M4","Global") <> "") Then
Your original options will not work on QTP Datatables as these are for uninitialised objects or variables. However, in QTP as soon as you create a parameter in the Datatable the first value gets initialised as blank (not to be confused with empty).
I agree with shreyansp.. The 3 options are for variables and objects
You could also use the below expression
If len(trim(DataTable.Value("M4","Global"))>0 Then
'Do code here
End If
Let's say I have a value that is passed to a process. What activity should i use to compare this value with another?
I know it may seem a foolish question, but i am new to this.
Assuming you are talking about BusinessWorks, comparing text values of XML attributes or elements is done with XPath using the '=' sign. You don't need to use any specific activity to do so. This can actually be done on any branch (with the "Success with condition" switch) or on the input tab of any activity.
For instance, if you want to compare the text values of 2 elements, you can use an XPath formula like this:
$Start/root/myString1 = $Start/root/myString2
This formula returns true if myString1 and myString2 have the same text value, false otherwise.
Then you can, for example, use this formula as a test condition for an "If" or a "Choice" statement on an input tab of any activity.