Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Clustered column average total

Hi - I have seen some similar posts on this but, being fairly unfamiliar with DAX, I haven't been able to figure out how to translate it into a solution for my problem. 

 

In short, I'm showing a weighted average for tenure by month but I want to show what the average is for the total time period shown in one graph ideally. 

 

I tried to post a screenshot but I'm not sure if it will show up here. It's pretty simple though - I have three months ("month" variable in the axis) each showing with their own value for "weighted tenure" (placed in the value area ). I want to show those three months AND the overall average for the time period. Right now, I'm just creating two bar charts and removing the "months" from the axis so as to get the averaged total. How do I get them on the same graph?

7 Replies

  • kentyler's avatar
    kentyler
    Solution Sage

    This is one of those cases where you will have to write some DAX. 
    Using the CALCULATE() function in DAX you can modify the filter context.

    So if you have a row showing data for a specific month you can CALUCLATE() the average for the 3 previous months, because CALCULATE allows you to use the ALL() function to temporarily remove the filter context for that row and reset it to consider the whole table, which you can then filter to get the 3 month average.

     

    If you'd like some help writing the DAX post a small sample power bi file, or an excel file with a sample of your data.

    I'm a personal Power Bi Trainer I learn something every time I answer a question

    The Golden Rules for Power BI

    1. Use a Calendar table. A custom Date tables is preferable to using the automatic date/time handling capabilities of Power BI. https://www.youtube.com/watch?v=FxiAYGbCfAQ
    2. Build your data model as a Star Schema. Creating a star schema in Power BI is the best practice to improve performance and more importantly, to ensure accurate results! https://www.youtube.com/watch?v=1Kilya6aUQw
    3. Use a small set up sample data when developing. When building your measures and calculated columns always use a small amount of sample data so that it will be easier to confirm that you are getting the right numbers.
    4. Store all your intermediate calculations in VARs when you’re writing measures. You can return these intermediate VARs instead of your final result  to check on your steps along the way.
    • Anonymous's avatar
      Anonymous
      Not applicable

      I created a sample pbix file but it won't let me drag and drop or copy-paste it here. how do I post it?