Forum Discussion
Using LOOKUPVALUE to compare two values with duplicates
New to DAX and its language.
I am trying to make a measure that gives feedback if a date from one column is greater than a date in another column. This is for multiple projects that are using the same base template with different dates for each. So duplicate columns are expected.
I tried this formula:
IsNetworkReadyOnTrackforUAT = IF(LOOKUPVALUE(Tasks[TaskFinishDate],Tasks[ShortTaskName],"NETWORK READY") > LOOKUPVALUE(Tasks[TaskFinishDate],Tasks[ShortTaskName],"UAT"), "IN TROUBLE","ALL GOOD")
this produces an error of multiple values. In researching, I tried using calculate with FIRSTNONBLANK like this:
IsNetworkReadyOnTrackforUAT = IF(
CALCULATE(
FIRSTNONBLANK(Tasks[TaskFinishDate], 1),
FILTER(ALL(Tasks),Tasks[ShortTaskName] = "UAT")
)
>
CALCULATE(
FIRSTNONBLANK(Tasks[TaskFinishDate], 1),
FILTER(ALL(Tasks),Tasks[ShortTaskName] = "NETWORK READY")
),
"IN TROUBLE",
"ALL GOOD")
This returns the same value for all of the rows (each row has a different value). Here is a snapshot of the data.
I think I'm missing something basic but unsure.
6 Replies
- lbendlinSuper User
your sample data doesn't match your description. It is unclear if you are trying to look up something in the same table or another table (LOOKUPVALUE is usually used for the latter). Please elaborate.
- tlhFrequent Visitor
No, all the data is contained within the same table.
Here is a summary of what I'm looking to do:
For each PROJECT NAME, find the TASK NAME called "UAT" and select the START date. For each PROJECT NAME, find the TASK NAME called "NETWORK READY" and select the START date. Comp[are these two START dates. If the START date for UAT is greater than the START date for "NETWORK READY", output "GOOD". Else, output "BAD".
I've highlighted two example columns out of my data.
The output here in this case should be GOOD.
TIA
- nandicResident Rockstar
tlh , below is formula, i added a condition: if we are missing data for either uat or network days return "no compare".
Result =
VAR _UatStart =
LOOKUPVALUE (
Tasks[Start],
Tasks[Task Name], "UAT",
Tasks[Project Name], Tasks[Project Name]
)
VAR _NetworkStart =
LOOKUPVALUE (
Tasks[Start],
Tasks[Task Name], "NETWORK READY",
Tasks[Project Name], Tasks[Project Name]
)
RETURN
IF (
Tasks[Task Name] IN { "UAT", "NETWORK READY" },
IF (
AND ( NOT ( ISBLANK ( _NetworkStart ) ), NOT ( ISBLANK ( _UatStart ) ) ),
IF ( _NetworkStart > _UatStart, "IN TROUBLE", "ALL GOOD" ),
"NO COMPARE"
)
)