cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

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
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors