Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
tlh
Frequent Visitor

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. 

 

Untitled.png

 

I think I'm missing something basic but unsure. 

6 REPLIES 6
lbendlin
Super User
Super 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.

tlh
Frequent 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. 

Untitled.png

 

The output here in this case should be GOOD. 

 

TIA

nandic
Memorable Member
Memorable Member

@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"
        )
    )


compare date start end uat.PNG

 

What is your plan for scenarios when either of the entries is missing or duplicated?

tlh
Frequent Visitor

Thanks for your help, but still not working. Here is what I'm doing. I duplicated the data into a table called TestTable and updated your formula.singlevalue.png

 

No plans for that yet. It should never happen as they are a part of the template used. 

nandic
Memorable Member
Memorable Member

@tlh there are fields underlined with red line, it means that there is no such field in your table/model. Check these and make sure you type it correctly.

Another thing, if there are no underlined fields and you get error that it cant get single value (as on screenshot) it means that there is still column in table which we need to add in lookup as on current lookup parameters dax cant find unique value.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors