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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

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
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

AugPowerBI_Carousel

Power BI Monthly Update - August 2024

Check out the August 2024 Power BI update to learn about new features.

September Hackathon Carousel

Microsoft Fabric & AI Learning Hackathon

Learn from experts, get hands-on experience, and win awesome prizes.