Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Simple IF measure

Just learning here and I searched the forum and well, was a bit overwhelmed by the multiple options for similar questions so thought I'd try my own. I can easily figure out how to add a column to do this but in reading the recommendation would be to use a measure instead since it is not a value that will be filtered.

 

My table looks like

CompanySalesCommissionableCommission
A100true 
B125false 
B200true 
C225true 

 

All I want to do is calculate the commissions (Sales * .10) when the Commissionable column is "true" but also that correctly calculates when aggregated at various levels, such as customer shown below. 

 

CompanyCommissions
A 
B 
C 

 

Thanks!

 

 

4 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Community Champion

    Anonymous - 

      Maybe:

    Measure =
      VAR __Table = SUMMARIZE('Table',[Company],[Commissionable],"__Sum",SUM('Table'[Sales]))
      VAR __Table2 = ADDCOLUMNS(__Table,"__Commission",IF([Commissionable],[__Sum]*.1,0))
    RETURN
      SUMX(__Table2,[__Commission])
    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks Greg, is it really that complicated? It's so exceeding easy to do this as a column. I trust you know what you're doing as I'm familiar with your book, so wondering if maybe I'm not asking the question the right way. It would seem to ,e that the temp table setup would only ever allow this to work if the aggregation was on company. What if it changed to account manager? 

      that commission column I'll trying to calculate is something that needs to summarized by any other possible values in the pivot. 

  • Anonymous ,

    new table

    summarize( table, Table[Company], "Commissions", sumx( Table, if([Commissionable] ="true",.1,0)*[Sales]))

     

    new measure

    sumx(summarize( table, Table[Company], "Commissions", sumx( Table, if([Commissionable] ="true",.1,0)*[Sales])),[Commissions])