Forum Discussion

Figueiredo_Luis's avatar
Figueiredo_Luis
Frequent Visitor
3 years ago

Percentage calcs

Dear PBI community - I am looking for an help to calculate the percentage between my actual sale vs target on a daily basis from my calendar. Please bear in mind that although I have a daily target for the sale it is different, there are some days without sales and i want for these days return a empty cel instead of "infinity".

 

Regards,

Figueiredo Luis

3 Replies

  • 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.

    • Figueiredo_Luis's avatar
      Figueiredo_Luis
      Frequent Visitor

      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.

       

       

  • Good day all - Could anyone help me regarding my lastest query?

     

    Thanks in advance, 

    Figueiredo_Luis