Forum Discussion
Fields
I have two table:
which reveal GrossTurnever=Q-ty*ProductPrice for every year and Margin=GrossTurnever2-GrossTurnever1
First picture below shows bi-directional relationship between tables.
Second picture shows measure for year 2016.
Hope help you.
Best regards,
20 Replies
- Thyago_RezendeResolver I
Hi,
First, you need to transform both columns year and its values in 2 columns only.
After that you can use:
GrossTurneverYear2016 =
SUMX (
FILTER (Table#2;
PriceYear = 2016
);
PriceValue2016 * RELATED ( Table#1[Q-ty])
)Regards,
- GrizmanHelper I
If I transform both columns year and its values in 2 columns I will get many to many relationship because id_product in first and second table will repeat
- Thyago_RezendeResolver I
You will can use Treatas pattern. It provides virtual relationship between tables.
Try do this:
http://www.sqlbi.com/articles/propagate-filters-using-treatas-in-dax/
- v-qiuyu-msftCommunity Support
Hi Grizman,
In your scenario, please open Query Editor, rename columns in second table to 2015, 2016, 2017, then select all these three columns, click Unpivot Columns button, apply the changes.
Then create a measure:
Diff =
var varMAX=MAXX(ALLSELECTED(Table2[Year]),[Year])
var varMin=MINX(ALLSELECTED(Table2[Year]),[Year])
return
(LOOKUPVALUE(Table2[Value],'Table2'[Year],varMAX,'Table2'[Id_product],MAX('Table1'[Id_product])) - LOOKUPVALUE(Table2[Value],'Table2'[Year],varMin,'Table2'[Id_product],MAX('Table1'[Id_product])))*MAX('Table1'[Q-ty])For details, you can download attached pbix file to have a look.
Best Regards,
QiuyunYu