Forum Discussion
SeanB004
2 years agoFrequent 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:
I get the below error:
1 Reply
- amitchandakSuper 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