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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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

@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. 

@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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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