Forum Discussion

wyattexplore's avatar
wyattexplore
Frequent Visitor
7 years ago

DAX Question regarding Measures in Visuals

Hey PBI,

 

I have a Dax Formula 

Productivity = 'Hours Table'[Total Billable Hours] / CALCULATE('Date Table'[Total Expected Hours])

 

The formula is working correctly for my table visual and showing the % Based on employee,  but when I use it in a line graph it is not displaying correct. I believe it is going to the date table, collecting all the Total Expected Hours based on the date slicer, and then dividing the Total Billable Hours for an employee PER DAY based on the [Total Expected Hours] based on the date slicer.

 

How do I adjust the DAX formula so on the visual level it calculates it per occurence?

 

See attached pictures:

 

4 Replies

  • TeigeGao's avatar
    TeigeGao
    Icon for Solution Sage rankSolution Sage

    HI wyattexplore ,

    The value of a measure depends on the context, the visual filter will change the context. In your scenario, when you use this measure in a table visual with employee name, the context is based on the employee name, while you are using the line visual with date filter, the context depends on the date.

    If you want to display the data of each employee based on the date, we will need to create measure for each employss with the filter [employee_name] = "***"

    Best Regards,

    Teige

    • wyattexplore's avatar
      wyattexplore
      Frequent Visitor

      TeigeGao wouldn't there be a way to just have it capture the relevant expected hours? It just seems like that defeats the point of writing a measure, if every time I add an employee to our database I have to go create new measures for each individual.  I also don't follow how that measure would look with your reply, could you expand on that at all?

      • TeigeGao's avatar
        TeigeGao
        Icon for Solution Sage rankSolution Sage

        You can also try to add the employee name to the Legend area.