Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Sumup Column based on Filter as Calculated Column

Hi Guys, Can someone help to get the formula in a calculated Column. (I derived it in Measure, but i need the same calculation in Calculated Column).

Measure Formula: Current Month Total = CALCULATE( SUM('Table1'[Month 1]), 'Table1'[Class] IN { "A" } ) 

how to get this done with Calculated Column?
Note: I need this Calculated Column since i was unable to add the Measure as "Page filter"
Thanks.

 

ClassMonth 1Month 2Month 3
A102022
B1213123
A131412
  • hi  Anonymous 

    Do you want show this expected output in power bi calculated table?

    If so, you need to create a new table like below:

    New table = SUMMARIZE(Table1,Table1[Subject],"Month 1",CALCULATE(SUM(Table1[Month1]),FILTER(Table1,Table1[Class]="A")))

    Result:

     

    here is sample pbix file, please try it.

     

    Regards,

    Lin

6 Replies

  • Create a column like

    Current Month = if('Table1'[Class] IN { "A" },'Table1'[Month 1],blank() )

    and choose Agg sum when use.

    But I not clear with data model you posted.

    In case you are looking for slicer to give you which measure then refer

    https://community.powerbi.com/t5/Desktop/Slicer-MTD-QTD-YTD-to-filter-dates-using-the-slicer/td-p/500115

     

    Appreciate your Kudos. In case, this is the solution you are looking for, mark it as the Solution.
    In case it does not help, please provide additional information and mark me with @

    Thanks. My Recent Blogs -Decoding Direct Query - Time Intelligence, Winner Coloring on MAP, HR Analytics, Power BI Working with Non-Standard TimeAnd Comparing Data Across Date Ranges
    Connect on Linkedin

    • Anonymous's avatar
      Anonymous
      Not applicable

      amitchandak this doesnt gives the correct value.., All i need is to filter "A" in Class and get the Month1 data for all A in calculated Column. Below is my exact version of data which i loaded in Power BI. 

      SubjectClassMonth1
      MathsA10
      MathsB13
      MathsA11
      ComputerA24

       

      The value which i expect is in Power BI Table is:

       

      SubjectMonth 1
      Maths21
      Computer24

       

      it just filter only "A" and provide the value against it.

      Measure Formula which works: Current Month Total = CALCULATE( SUM('Table1'[Month 1]), 'Table1'[Class] IN { "A" } ) 

      and same formula i need in Calcluated Column...

      • v-lili6-msft's avatar
        v-lili6-msft
        Icon for Community Support rankCommunity Support

        hi  Anonymous 

        Do you want show this expected output in power bi calculated table?

        If so, you need to create a new table like below:

        New table = SUMMARIZE(Table1,Table1[Subject],"Month 1",CALCULATE(SUM(Table1[Month1]),FILTER(Table1,Table1[Class]="A")))

        Result:

         

        here is sample pbix file, please try it.

         

        Regards,

        Lin

  • v-lili6-msft's avatar
    v-lili6-msft
    Icon for Community Support rankCommunity Support

    hi  Anonymous 

    Just adjust the formula as below:

    CALCULATE( SUM('Table1'[Month 1]), FILTER(ALL(Table1),'Table1'[Class] IN { "A" } ))
     
    Regards,
    Lin

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      v-lili6-msft  this formula which you provided sums all i guess.., i am not getting the value only for that particular selection. 😞