Forum Discussion
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
- MariuszCommunity Champion
- AnonymousNot 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.- CmcmahanResident 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.
- AnonymousNot applicable
Asking Questions on Power BI Forum - https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490
