Forum Discussion

mrvamsidhar's avatar
mrvamsidhar
Helper I
8 years ago
Solved

Calculate Total and %

Hello, I am working on Power-Bi Dashboard to set up simple table using below. I need to show % of each product and total sales in a Month. I am having Table1. My output should be Table 2. 

 

Here is what I am thinking.

  1. Create a measure to identify total sales in Month.
  2. DIVIDE [Actual sales by product] with [1].

For (1), I added thismeasure TotalSales = CALCULATE(SUM('Table'[Sales]),GROUPBY('Table','Table'[Month])). But this is not working.

If i am selecting only month column then , i see my measure is working. But If i add product it is not working. My Total sales column should display total sales in month having Month and Product columns in my view.

Any help or any better idea?

 

Table1. Data Available

 

MonthProductSales
JUNEA100
JUNEB120
JUNEC20
JULYA30
JULYB150
JULYC80

 

Table2. Data with New measures.

 

MonthProductSalesTotal Sales% Sales
JUNEA10024041.67%
JUNEB12024050.00%
JUNEC202408.33%
JULYA3026011.54%
JULYB15026057.69%
JULYC8026030.77%
  • Thanks. I figured it out. CALCULATE(SUM('Table'[Sales]),GROUPBY('Table','Table'[Month]),ALL('Table')).

     

    thats it. - I need to tell to DAX exclude all filters. so ALL() did the trick.

2 Replies

    • mrvamsidhar's avatar
      mrvamsidhar
      Helper I

      Thanks. I figured it out. CALCULATE(SUM('Table'[Sales]),GROUPBY('Table','Table'[Month]),ALL('Table')).

       

      thats it. - I need to tell to DAX exclude all filters. so ALL() did the trick.