Forum Discussion

nataliafm31's avatar
nataliafm31
Frequent Visitor
6 years ago
Solved

Multiply Columms

Hello!

Anyone could help me, pls? I need to multiply two values, but they have a conditional. For example: I need to multiply the number of fruits per some tax, but the tax depends of the kind of fruit, like
(

Fruit Tax = IF('Fruits'[fruit_name]="Banana";[Banana Tax];IF('Fruits'[fruit_name]="Apple";[Apple Tax];[Orange Tax])) -> it's a columm.

 

Fruit Type       Count of fruits          TAX        Value
Apple                  500                       0.2             X
Banana               200                        0.1             Y

Orange               350                        0.5             Z

How can I obtain X, Y and Z? There is any way, without creat a filtered value for each fruit and than, multiply per Fruit Tax?

  • Information provided in a couple of posts, not making it clear. But summarize can help if data is at multiple levels

    sumx(summarize(Table,Table[Fruit Name],"_Sum",sum(Table[Fruit Qty]),"_Max",Table[Tax]),[_Sum]*[_Max])

     

5 Replies

  • VasTg's avatar
    VasTg
    Icon for Memorable Member rankMemorable Member

    nataliafm31 

     

     

    Could you split the data into two tables?

    One with Fruit name and corresponding tax and the other with fruit name, cnt of fruits. Define a relationship based on fruits column and create a measure directly. Please post complete sample input data. I could not related the measure you have with the provided sample.

    • nataliafm31's avatar
      nataliafm31
      Frequent Visitor

      VasTg I can split - one table with "fruit_name" and Quantity and other table with "fruit_name" and its taxes and use a related function. The problem is that quantity is a calculated value and taxes is a function that depends of fruit type.

      I can't share my data, it's confidential, but i will try to give a better example:

      register_id      type_of_fruit     col_3         col_4     col_5
      4512d           banana             ...               ...          ...   

      s345c3          apple
      457120         orange
      48762w         apple

      Then, I created some calculated measures: Banana_tax, Orange_tax, Apple_tax as float numbers (ex: Banana_tax = 0,07).

      And so, I created a calculated columm, with the conditional I wrote before, to define the correct tax for each fruit. Finally, I want to multiply the correct tax X count(register_id) for each type of fruit.

      I tried to use so many aproaches, but none worked until now 😞




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

        Hi nataliafm31 

        Measure suggested by amitchandak should work.
        If it is sloved, could you kindly accept it as a solution to close this case?
        If not, please let me know.
         
        Best Regards
        Maggie
  • Information provided in a couple of posts, not making it clear. But summarize can help if data is at multiple levels

    sumx(summarize(Table,Table[Fruit Name],"_Sum",sum(Table[Fruit Qty]),"_Max",Table[Tax]),[_Sum]*[_Max])

     

    • nataliafm31's avatar
      nataliafm31
      Frequent Visitor

      Thank You so much! 🙂

      It worked - I just replace Table[Tax] per its expression - I could not call it directly since it is a calculated columm and wasnt allowed when I tried here.