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
RevOps608
Helper II
Helper II

Count Id's where it has at one time been two different values

I have a 'Opportunity Field History' table. Every row contains a stage change for an opportunity. I need to count opportunities Id's where within the 'New Value' been both  "4 - Estimate Generated" and "6 - Closed Won". Because they're not in both stages at the same time, I cannot get my filters to work correctly in my summarize formula. If I use || it counts opportunities that have been in eith stage but not both and && draws and gets zero because they cant be in the stage at the same time. I need to calculate this for both 2023 and 2024.

 

COUNTROWS(
       SUMMARIZE(
                   FILTER(
           'Opportunity Field History',
           'Opportunity Field History'[NewValue] = "4 - Estimate Generated" ||
           'Opportunity Field history'[NewValue] = "6 - Closed Won"),
           'Opportunity Field History'[OpportunityId],
           'Opportunity Field History'[NewValue],
           'Opportunity Field History'[Created_YR])
)

 

 

stage change.png

1 ACCEPTED SOLUTION
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try something like below whether it produces the expected result.

 

expected result measure: =
VAR _t01 =
    SUMMARIZE (
        FILTER (
            'Opportunity Field History',
            'Opportunity Field History'[NewValue] = "4 - Estimate Generated"
                && 'Opportunity Field History'[Created_YR] IN { 2023, 2024 }
        ),
        'Opportunity Field History'[OpportunityId]
    )
VAR _t02 =
    SUMMARIZE (
        FILTER (
            'Opportunity Field History',
            'Opportunity Field History'[NewValue] = "6 - Closed Won"
                && 'Opportunity Field History'[Created_YR] IN { 2023, 2024 }
        ),
        'Opportunity Field History'[OpportunityId]
    )
VAR _intersectlist =
    INTERSECT ( _t01, _t02 )
RETURN
    COUNTROWS ( _intersectlist )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

View solution in original post

2 REPLIES 2
Jihwan_Kim
Super User
Super User

Hi,

I am not sure if I understood your question correctly, but please try something like below whether it produces the expected result.

 

expected result measure: =
VAR _t01 =
    SUMMARIZE (
        FILTER (
            'Opportunity Field History',
            'Opportunity Field History'[NewValue] = "4 - Estimate Generated"
                && 'Opportunity Field History'[Created_YR] IN { 2023, 2024 }
        ),
        'Opportunity Field History'[OpportunityId]
    )
VAR _t02 =
    SUMMARIZE (
        FILTER (
            'Opportunity Field History',
            'Opportunity Field History'[NewValue] = "6 - Closed Won"
                && 'Opportunity Field History'[Created_YR] IN { 2023, 2024 }
        ),
        'Opportunity Field History'[OpportunityId]
    )
VAR _intersectlist =
    INTERSECT ( _t01, _t02 )
RETURN
    COUNTROWS ( _intersectlist )

 

If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.


Visit my LinkedIn page by clicking here.


Schedule a meeting with me to discuss further by clicking here.

Thank you Jihwan_Kim. This worked. I did try a similar version using UNION and count. It wasnt working correctly though. I'll dig into it later. This is the first time I've used INTERSECT.

 

Thanks again

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!

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.