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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

getting a count of different statuses in a column

Hello Community -  Well, I thought this was going to be simpler than this.  

 

I have a Salesforce column for "status" in my Opportunity table.    I have the "closed date" column in that table connected to my main date table in an inactive relationship.    In essence, what I am trying to do is get a count of the number of "Won" or "Lost" opportunities based on the closed date.    I was hoping to use variables, but this formula below is not working at all.  Any help is appreciated!

Count of Status =
VAR _WonCount = CALCULATE(COUNTROWS('Sf_Opportunity Line'),'Sf_Opportunity Line'[Status__c] = "Won",USERELATIONSHIP('Dim_Date Table'[Date],'Sf_Opportunity Line'[CloseDate]))
VAR _LostCount = CALCULATE(COUNTROWS('Sf_Opportunity Line'), 'Sf_Opportunity Line'[Status__c] = "Lost",USERELATIONSHIP('Dim_Date Table'[Date],'Sf_Opportunity Line'[CloseDate]))
RETURN
IF(ISINSCOPE('Sf_Opportunity Line'[Status__c]) = "Won",_WonCount,_LostCount)
1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 
Since you are slicing by Status the use only

Count of Status =
CALCULATE (
    COUNTROWS ( 'Sf_Opportunity Line' ),
    USERELATIONSHIP ( 'Dim_Date Table'[Date], 'Sf_Opportunity Line'[CloseDate] )
)

View solution in original post

1 REPLY 1
tamerj1
Super User
Super User

Hi @Anonymous 
Since you are slicing by Status the use only

Count of Status =
CALCULATE (
    COUNTROWS ( 'Sf_Opportunity Line' ),
    USERELATIONSHIP ( 'Dim_Date Table'[Date], 'Sf_Opportunity Line'[CloseDate] )
)

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

Check out the June 2025 Power BI update to learn about new features.

June 2025 community update carousel

Fabric Community Update - June 2025

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