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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
SeanB004
Frequent Visitor

A function selectedValue was used where a True/False expression was expected. This is not allowed er

Hi I have a dax formula thats supposed to calculate the percentage of the number of sales transactions based on a selected status. However when I enter in this dax formula: 

Percentage New_ =
VAR SelectedStartDate = MIN(CompanyOpportunities[opportunity_date])
VAR SelectedEndDate = MAX(CompanyOpportunities[opportunity_date])
VAR StatusOppts =
CALCULATE(
COUNTROWS(CompanyOpportunities),
CompanyOpportunities[status] = SELECTEDVALUE(CompanyOpportunities[status]),
CompanyOpportunities[opportunity_date] >= SelectedStartDate,
CompanyOpportunities[opportunity_date] <= SelectedEndDate
)
VAR TotalOppts =
CALCULATE(
COUNTROWS(CompanyOpportunities),
CompanyOpportunities[opportunity_date] >= SelectedStartDate,
CompanyOpportunities[opportunity_date] <= SelectedEndDate
)
RETURN
DIVIDE(StatusOppts, TotalOppts, 0)

I get the below error:
SeanB004_0-1700579088700.png

 

1 REPLY 1
amitchandak
Super User
Super User

@SeanB004 , when the values are from the same table you do not need to handle

 

You need to create a measure

 

divide(COUNTROWS(CompanyOpportunities), calculate(COUNTROWS(CompanyOpportunities), removefilters(CompanyOpportunities[status]) ) )

 

https://www.linkedin.com/pulse/five-recent-power-bi-functions-you-should-use-more-often-amit-chandak

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors