Search code examples
powerbipowerbi-custom-visuals

Creating and Referring to a Grand total for a future calculation in Power BI


Attach is a screenshot of my tables and columns/values I have. I am very new to power BI and have searched for a solution to my problem but it all leads to a running total which I does not solve my issue.

I am trying to create a future calculated measure that needs to reference a grand total of total meals as so (grand total total meals * Fairshare %). I could create a column/measure with the grand total written into the equation but i would like to have this column dynamically change since new data will be updated on a monthly basis. The logic should be to have the new column just refer to the grand total meals (whatever value it is; 788150 in this case) multiplied with fairshare % column for each row but I can't see a way to refer to a grand total in power BI.

TTable


Solution

  • Let's say you have a DAX measure of:

    Total Meals = [KC_Total_Meal] + [WPP_Total_Meals] + [SP_Total_meals]
    

    That measure when it's calculated will be adjusted by the row context in your table. (I'm assuming you have a date or location to the left of your screen print.) If you are new to "context" in Power BI, try reading through this helpful reference card.

    To remove the row context to get a true Grand Total, use the ALL() function within a CALCULATE() function. ALL() returns all the rows in a table ignoring any filters or row/column context that might have been applied.

    Grand Total Meals = CALCULATE( [Total Meals]), ALL(Meals_Table))
    

    Depending on the situation, you may need similar functions such as ALLEXCEPT() or EARLIER() or REMOVEFILTERS().