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

We've captured the moments from FabCon & SQLCon that everyone is talking about, and we are bringing them to the community, live and on-demand. Starts on April 14th. Register now

Reply
Anonymous
Not applicable

DAX check later status of contract

I have the following problem that I would love to solve in DAX.

Here is the data:

 

Contract DATE STATUS
C0001 06/08/2019 S0001
C0001 27/09/2019 S0002
C0004 07/09/2019 S0001
C0004 10/10/2019 S0002

 

Given a time range for instance August and September 2019 , I need to know the contracts that have been in S001 but got no later S0002 (within the date range). In this case solution would C0004.

 

Thank you for your help in advanced 🙂

 

 

3 REPLIES 3
Anonymous
Not applicable

The metric is per contract CXXXX and the solution would be:

Contract | Date              |  STATUS | Metric

C0004     |  07/09/2019 |   S0001   | 1

 

if we get rid of contract, i should count the number of contracts that has been on S0001 but no S0002 within the time range

 

because its the latests row that has been on S0001 but no S0002 in the given filter range.

 

 

Anonymous
Not applicable

I have achieved the following 

TEST =
var S0001 = CALCULATE(DISTINCTCOUNT(OperationsStatusHistory[CONTRACT_ID]);
'Status'[STATUS_NK] = "S0001";
FILTER('StatusDate'; 'StatusDate'[MONTH_ID] IN VALUES('Date'[MONTH_ID]))
)
var S0002 = CALCULATE(DISTINCTCOUNT(OperationsStatusHistory[CONTRACT_ID]);
'Status'[STATUS_NK] = "S0002";
FILTER('StatusDate'; 'StatusDate'[MONTH_ID] IN VALUES('Date'[MONTH_ID]))
)
RETURN S0001 = 1 && S0001 = 0
 
Its works ok when contract is rows in a table but when used in a KPI box it always says 0  ;_;
 
 
dax
Community Support
Community Support

Hi gonzalomoran, 

Did you want to get below result?

332.PNG

You could try below measure

Measure 2 =
VAR maxd =
    CALCULATE ( MAX ( 'Table'[DATE] ), ALLEXCEPT ( 'Table', 'Table'[STATUS] ) )
RETURN
    CALCULATE (
        MIN ( 'Table'[Contract] ),
        FILTER ( ALLEXCEPT ( 'Table', 'Table'[STATUS] ), 'Table'[DATE] = maxd )
    )

Best Regards,
Zoe Zhi

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.

Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.