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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Measure filter to select 2 statuses, then select newest status

I have a status history table that shows the various statuses an opportunity has transistioned through and the date it first hit that status.  What I am trying to do is create a measure that finds every deal that hit 2 of the statuses then selects the newest of the two.  I first created the measure with an or function to select the two statuses and hoped it would select the lastest, but that was wishful thinking.  I then tried to add a max date function but it seems to be eliminating opps that have transitioned beyond the two statuses.  Here is the function I've got so far....

 

Pipeline Total Volume 2 = CALCULATE(SUM('Status History'[Finance Amount]), 'Status History'[Application Status] = "Funding Review" || 'Status History'[Application Status] = "Documents Received" && 'Status History'[Status Date] = Max ('Status History'[Status Date])
 
The funding review status comes after documents received.  Not all opps have transistioned to funding review, and not all do.
2 ACCEPTED SOLUTIONS

If you don't have duplicated Finance Amount rows in your table, then you can just write

CALCULATE (
    SUM ( 'Status History'[Finance Amount] ),
    'Status History'[Application Status] IN { "Funding Review", "Documents Received" }
)

 

If your data isn't set up so that Finance Amount is additive (where the above works), then you'll need to provide some example data and desired result since the correct measure heavily depends on how the data is set up.

View solution in original post

Got it. I'd recommend adding a calculated column on the table

IsLastStatus =
VAR MaxDate =
    CALCULATE (
        MAX ( 'Status History'[Status Date] ),
        ALLEXCEPT ( 'Status History', 'Status History'[Application Number] )
    )
VAR LastStatus =
    CALCULATE (
        MAX ( 'Status History'[Application Status] ),
        ALLEXCEPT ( 'Status History', 'Status History'[Application Number] ),
        'Status History'[Status Date] = MaxDate
    )
RETURN
    'Status History'[Application Status] = LastStatus

 

If you have this, then the measure I suggest only needs a small modification.

CALCULATE (
    SUM ( 'Status History'[Finance Amount] ),
    'Status History'[Application Status] IN { "Funding Review", "Documents Received" },
    'Status History'[IsLastStatus]
)

(Since [IsLastStatus] is a boolean it can function without specifying = TRUE. )

View solution in original post

8 REPLIES 8
AlexisOlson
Super User
Super User

Logically, A || B && C = A || ( B && C ) which is not the same as ( A || B ) && C, so you might want some parentheses around your || combination.

 

Beyond that though, it's not quite clear to me if the deal must hit both statuses or not to be counted and whether you want your measure to return and an amount, a date, or a status.

Anonymous
Not applicable

I want the measure to return a sum of all the finance amounts for deals that are in either docs received or funding review, and if the opp is in both I only want to count the finance amount once for the sum.  

If you don't have duplicated Finance Amount rows in your table, then you can just write

CALCULATE (
    SUM ( 'Status History'[Finance Amount] ),
    'Status History'[Application Status] IN { "Funding Review", "Documents Received" }
)

 

If your data isn't set up so that Finance Amount is additive (where the above works), then you'll need to provide some example data and desired result since the correct measure heavily depends on how the data is set up.

Anonymous
Not applicable

Here is how the data is structure

Application NumberApplication StatusStatus DateFunding AnalystFinance Amount
10993Documents Received9/21/2021 0:00 $55,000
10993Funding Review9/21/2021 0:00 $55,000
22824Documents Received9/16/2021 0:00 $164,890
22824Funding Review9/16/2021 0:00 $164,890
25970Documents Received9/20/2021 0:00 $198,481
25970Funding Review9/20/2021 0:00 $198,481
29009Documents Received9/27/2021 0:00 $91,923
29009Funding Review9/27/2021 0:00 $91,923
30541Funding Review9/20/2021 0:00 $425,000
30715Documents Received9/2/2021 0:00 $1,347,800
30715Funding Review9/21/2021 0:00 $1,347,800
32267Documents Received9/3/2021 0:00 $6,251
32267Funding Review9/3/2021 0:00 $6,251
32412Documents Received9/1/2021 0:00 $38,000
32412Funding Review9/2/2021 0:00 $38,000
32452Documents Received9/27/2021 0:00 $159,375
32452Funding Review9/27/2021 0:00 $159,375
32476Documents Received9/29/2021 0:00 $180,000
32615Documents Received9/3/2021 0:00 $74,264
32615Funding Review9/3/2021 0:00 $74,264
32729Documents Received9/14/2021 0:00 $403,500
32729Funding Review9/27/2021 0:00 $403,500
32944Documents Received9/10/2021 0:00 $10,000
32944Funding Review9/10/2021 0:00 $10,000
33006Documents Received9/30/2021 0:00 $650,000
33081Documents Received9/16/2021 0:00 $241,000
33327Documents Received9/30/2021 0:00 $20,000
33427Funding Review9/22/2021 0:00 $2,947,492

There are more columns but those are the ones relevant to this measure.  The status order would be docs received, then funding review. The time isn't currently captured as part of the stage transisions, but I do have a table that has the status orders as...
status order.PNG

 

The goal would be to only count the finance amount of apps once in the sum measure that appear in both statuses.

Got it. I'd recommend adding a calculated column on the table

IsLastStatus =
VAR MaxDate =
    CALCULATE (
        MAX ( 'Status History'[Status Date] ),
        ALLEXCEPT ( 'Status History', 'Status History'[Application Number] )
    )
VAR LastStatus =
    CALCULATE (
        MAX ( 'Status History'[Application Status] ),
        ALLEXCEPT ( 'Status History', 'Status History'[Application Number] ),
        'Status History'[Status Date] = MaxDate
    )
RETURN
    'Status History'[Application Status] = LastStatus

 

If you have this, then the measure I suggest only needs a small modification.

CALCULATE (
    SUM ( 'Status History'[Finance Amount] ),
    'Status History'[Application Status] IN { "Funding Review", "Documents Received" },
    'Status History'[IsLastStatus]
)

(Since [IsLastStatus] is a boolean it can function without specifying = TRUE. )

Anonymous
Not applicable

Is there a way to modify that so it picks the last status between those two, because there are other statuses after the two (documents received, and Funding Review).  Like excluding funded?

Sure. Add the same filter to both CALCULATE functions in [IsLastStatus].

'Status History'[Application Status] IN { "Funding Review", "Documents Received" }
Anonymous
Not applicable

Cool, I'll try this tomorrow.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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