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