Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago

Measure Conditional

Hello, 

 

I need to calculate in the same measure the following problem: 

 

I have prices for 2018 and 2019, and in the same measure, I need to calculate the quatity*prices for 2018 if the date is before 01-10-2019, after that, I need to calculate quantitty*prices 2019. 

 

Can someone help me, please?

 

Thank you

8 Replies

  • Mariusz's avatar
    Mariusz
    Community Champion

    Hi Anonymous 

     

    Can you provide a data sample?

     

    Best Regards,
    Mariusz

    Please feel free to connect with me.
    Mariusz Repczynski

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Mariusz , 

       

      I did it just right now. 

       

      I just did a lot of ifs with calculates...



       

      IF(sum('table'[date]<DATE[yyyy;mm;dd);

       

      (IF(SUM('Tabela Categoria'[CAT_2])=1;CALCULATE(SUM('Table Sales'[Sales Price]);'Table Sales'[Year]=2018);IF(SUM('Tabela Categoria'[CAT_2])=2;CALCULATE(SUM('Table Sales'[Sales Price]);'Table Sales'[Year]=2018);IF(SUM('Tabela Categoria'[CAT_2])=3;CALCULATE(SUM('Table Sales'[Sales Price]);'VTable Sales'[Year]=2018)))));(IF(SUM('Tabela Categoria'[CAT_2])=1;CALCULATE(SUM('Table Sales'[Sales Price]);'Table Sales'[Year]=2019);IF(SUM('Tabela Categoria'[CAT_2])=2;CALCULATE(SUM('Table Sales'[Sales Price]);'Table Sales'[Year]=2019);IF(SUM('Tabela Categoria'[CAT_2])=3;CALCULATE(SUM('Table Sales'[Sales Price]);'Table Sales'[Year]=2019)))))
       
       
      Do you believe you know a easier way? 
       
      Thank you for your feedback.
      • Cmcmahan's avatar
        Cmcmahan
        Resident Rockstar

        There definitely is an easier way, but it depends on how your data is modeled. Could you share a sample of the raw data with us so we can see how it is set up in your data table?  

         

        Also, if you could share a mockup of your desired visual as well, that would help too. It looks like you're trying to control and account for every possible category/year combination instead of letting your visual handle the context changes for you.