Forum Discussion

rickylee's avatar
rickylee
Icon for Helper III rankHelper III
7 years ago
Solved

Filter in calculate( )

Hello,

In my table, I have a "Total order billing (include refund)" which is the amount for a transaction. I also have a column "refund" which contains either True or False only.

To find out the total amount when the refund column is set to True, I have the following measure: 

 

Total refund = CALCULATE([Total order billing (include refund)], salesorders[refund]="True") 


Surprisingly, the above formula does not work, I have to resort to this one:

Total refund = CALCULATE([Total order billing (include refund)], filter(ALL(salesorders[refund]),SEARCH("True",salesorders[refund],1,0)))

 

The second formula is a search which takes long. Is there any reason why I cannot use the first formula?

 

Please notice Total order billing (include refund) is a measure of: 
Total order billing (include refund) = SUM(salesorders[totalamount])

  • rickylee Please try this, if your "refund" field is Text Data type

     

    Total refund amount = CALCULATE(SUM([Total billing]), Test[Refund]="True")

    If "refund" field is Boolean data type then use 

     

    Total refund amount = CALCULATE([Total billing], Test[Refund]=True())

5 Replies

  • Hello PattemManohar,

     

    I have form the following sample table:


    Order     Billing    Refund

    1100TRUE
    2200FALSE
    3300FALSE


    There are two meausures:
    Total billing = SUM(Test[Billing])

    Total refund amount = CALCULATE([Total billing], Test[Refund]="True")


    If you try to display "Total refund amount", it does not work. However, I think the calculate() function is used correctly.

    Thanks,
    Ricky

    • Zubair_Muhammad's avatar
      Zubair_Muhammad
      Icon for Community Champion rankCommunity Champion

      rickylee

       

      Is the Refund column a text data type column?

       

      What if you use TRUE()

       

      Total refund amount = CALCULATE([Total billing], Test[Refund]=True())

       

       

    • venug20's avatar
      venug20
      Icon for Resolver I rankResolver I

      rickylee

       

      You can use below formula to get values.....

       

      Refunamt = CALCULATE(SUM('Billing-Refund'[Billing]), 'Billing-Refund'[Refund]=TRUE())

       

       

       

      If it is soultion for your query, Pls accept as solution. It is helpful to others....

       

    • PattemManohar's avatar
      PattemManohar
      Icon for Community Champion rankCommunity Champion

      rickylee Please try this, if your "refund" field is Text Data type

       

      Total refund amount = CALCULATE(SUM([Total billing]), Test[Refund]="True")

      If "refund" field is Boolean data type then use 

       

      Total refund amount = CALCULATE([Total billing], Test[Refund]=True())