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
ChPetru
Helper I
Helper I

Poor performance IF measure

Hello,

 

I have created a measure that has horrible performance:

_Active License = 
VAR ExpiresInFuture =
    LASTDATE ( LineItem[Opportunity Line End Date] )
        >= LASTDATE ( ReferenceDate[Reference Date] )
VAR ExpiresInPast =
    LASTDATE ( LineItem[Opportunity Line End Date] )
        <= LASTDATE ( ReferenceDate[Reference Date] )
VAR StartsInFuture =
    FIRSTDATE ( LineItem[Opportunity Line Start Date] )
        >= LASTDATE ( ReferenceDate[Reference Date] )
VAR StartsInPast =
    FIRSTDATE ( LineItem[Opportunity Line Start Date] )
        <= LASTDATE ( ReferenceDate[Reference Date] )
RETURN
    IF (
        ExpiresInPast,
        "Expired",
        IF (
            StartsInPast && ExpiresInFuture,
            "Active",
            IF ( StartsInFuture && ExpiresInFuture, "Future", "Error" )
        )
    )

 

This is not even running for low granularity.. not sure how I can optimize it to run under 3ms. 

The output should tell me if a license if expired, active or future based on the row level start and end date.

 

Thank you

 

2 REPLIES 2
PabloDeheza
Solution Sage
Solution Sage

Hi there!

One thing you can try is splitting the variables so you dont make the engine compute the same thing multiple times. The engine is sometimes smart enough to realise that something was already computed but not always.

Try one variable for 

LASTDATE ( LineItem[Opportunity Line End Date] )

One for

LASTDATE ( ReferenceDate[Reference Date] )

And one for

FIRSTDATE ( LineItem[Opportunity Line Start Date] )

Variables are only computed once, since you are using one of those expression 4 times, that should help at least something on your performance.

Let me know if that helps! 

Sorry, it did not help at all. I actually broke down the measure to:

 

_License Active =
IF (
    FIRSTDATE ( LineItem[Opportunity Line Start Date] )
        <= LASTDATE ( ReferenceDate[Reference Date] )
        && LASTDATE ( LineItem[Opportunity Line End Date] )
            >= LASTDATE ( ReferenceDate[Reference Date] ),
    TRUE (),
    FALSE ()
)

 

and it still has huge performance issues. 

How can I optimize this?

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