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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors