Forum Discussion
Percentage calcs
To calculate the percentage between actual sales and target on a daily basis while avoiding division by zero errors, you can use the following DAX formula:
```
Sales % Target =
IF(
ISBLANK([Total Sales]),
BLANK(),
DIVIDE([Total Sales], [Daily Target], 0)
)
```
Here's what this formula does:
- The IF function checks if the Total Sales value for the current day is blank. If it is, then the formula returns a blank value. This will handle the case where there are no sales for a particular day.
- If the Total Sales value is not blank, then the DIVIDE function is used to calculate the ratio of Total Sales to Daily Target. The third argument of the DIVIDE function is set to 0, which means that if the Daily Target value is 0, the formula will return 0 instead of "infinity".
To use this formula in your report, you can create a new measure and replace "Total Sales" and "Daily Target" with the names of the relevant columns in your data model. You can then use this measure in a table or chart visualization to display the percentage of actual sales versus target for each day in your calendar.
Hi Ghousuddin - unfortunatily it didn't work, unless i need to have two mesures for [Total Sales] as well as [Daily Target] cos i don't see on the formula referencing the date column, I am attacheing the snapshot of the data below with the highlighted column that we need to look at.