The If-Else function is a block with three entries. Depending on the Boolean value of the entry, named condition, a "true" or "false" value will be returned.
In the following sample, if the total number of hours worked for each employee is greater than 4000, in the "promote" field, the "yes" value will be inserted. Otherwise, the "no" value will be inserted.
The output lists the name of the employee, the hours worked in each department and if a promotion must be granted to him/her.
Note:
• | The above example is part of the If-Else.dax document, located in the Samples/Job Samples folder. |
Output:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<ns:root xmlns:ns="http://www.tempuri.org/XML">
<ns:emp last-name="Brown" first-name="John">
<ns:hist hours-worked="300" department="Accounting"/>
<ns:hist hours-worked="500" department="Sales"/>
<ns:hist hours-worked="3000" department="Development"/>
<ns:hist hours-worked="100" department="Accounting"/>
<ns:promote value="no"/>
</ns:emp>
<ns:emp last-name="Jane" first-name="Mary">
<ns:hist hours-worked="1000" department="Accounting"/>
<ns:hist hours-worked="8000" department="Sales"/>
<ns:hist hours-worked="5000" department="Development"/>
<ns:promote value="yes"/>
</ns:emp>
<ns:emp last-name="Clark" first-name="Arthur">
<ns:promote value="no"/>
</ns:emp>
</ns:root>