Forum Discussion
How to do an inter calculation in matrix ?
- 4 years ago
Birinder , from where the fa20 , and q2 2021 is coming?
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.
- 4 years ago
Birinder , If you need diff between two period, separated by 1 period or one year. With help from period/date table, Period rank and Year , Period number you can do
example
new column in period or date table
Period Rank = RANKX(all(Period),Period[year period],,ASC,Dense)
measure
This Period = CALCULATE(sum('Table'[Qty]), FILTER(ALL(Period),Period[Period Rank]=max(Period[Period Rank])))
Last Period = CALCULATE(sum('Table'[Qty]), FILTER(ALL(Period),Period[Period Rank]=max(Period[Period Rank])-1))This Period = CALCULATE(sum('Table'[Qty]), FILTER(ALL(Period),'Period'[Year]=max('Period'[Year]) && Period[Period]=max(Period[Period])))
Last year same Period = CALCULATE(sum('Table'[Qty]), FILTER(ALL(Period),'Period'[Year]=max('Period'[Year])-1 && Period[Period]=max(Period[Period])))Actually, I am somewhat confused if you are looking for something other than period diff. Sorry for that
- 4 years ago
Hi, Birinder
I recovered some data by the picture you gave me, and I hope it will restore your problem.
Measure = VAR n1 = CALCULATE ( MAX ( 'Table'[Price] ), FILTER ( 'Table', [Period] = "Q2 2021" && [Currency] = MAX( 'Table'[Currency] ) && [Methods] = MAX( 'Table'[Methods] ) ) ) VAR n2 = CALCULATE ( MAX ( 'Table'[Price] ), FILTER ( 'Table', [Period] = "FA 2020" && [Currency] = MAX('Table'[Currency] ) && [Methods] = MAX('Table'[Methods] ) ) ) RETURN n1 - n2Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- 4 years ago
Hi, Birinder
I simulated some more data, and I hope this time it fits your situation.
Use the function to create a new table.
Table = SELECTCOLUMNS(Dim_facts,"Currencies_ID",[Currencies_ID])Add calculated columns using lookupvalue.
Price = LOOKUPVALUE(Dim_facts[Price],Dim_facts[Currencies_ID],[Currencies_ID])Price = LOOKUPVALUE(Dim_facts[Price],Dim_facts[Currencies_ID],[Currencies_ID])Junk_Dimension_id = LOOKUPVALUE(Dim_facts[Junk_Dimension_id],Dim_facts[Currencies_ID],[Currencies_ID])Methods = LOOKUPVALUE(Dim_methods[Methods],Dim_methods[Junk_Dimension_id],[Junk_Dimension_id])Period_id = LOOKUPVALUE(Dim_facts[Period_id],[Currencies_ID],[Currencies_ID])Period = LOOKUPVALUE(Dim_period[Period],Dim_period[Period_id],[Period_id])Measure just uses the function in the previous reply.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- 4 years ago
Hi, Birinder
This source data is really too large.
By the same token, both Junk_Dimension_id and Period_id can be used as the columns selected for the new table.
Table = SELECTCOLUMNS(Dim_facts,"Junk_Dimension_id",[Junk_Dimension_id])Table = SELECTCOLUMNS(Dim_facts,"Period_id",[Period_id])Hope this helps you.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi, Birinder
I recovered some data by the picture you gave me, and I hope it will restore your problem.
Measure =
VAR n1 =
CALCULATE (
MAX ( 'Table'[Price] ),
FILTER (
'Table',
[Period] = "Q2 2021"
&& [Currency] = MAX( 'Table'[Currency] )
&& [Methods] = MAX( 'Table'[Methods] )
)
)
VAR n2 =
CALCULATE (
MAX ( 'Table'[Price] ),
FILTER (
'Table',
[Period] = "FA 2020"
&& [Currency] = MAX('Table'[Currency] )
&& [Methods] = MAX('Table'[Methods] )
)
)
RETURN
n1 - n2
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Birinder4 years ago
Helper III
Hi v-zhangti
Thank you for such great effort on my problem.
But below I also mentioned that all the tables are from different dimensions. Its a live data. There are dimensions and each dimension has multiple tables and within those tables there lies the data.
Do you any ideas on how we can achieve this ?- v-zhangti4 years ago
Community Support
Hi, Birinder
The fact that you can compose a matrix view like this means that there are associations in each table. You might consider using the LOOKUPVALUE function to aggregate the fields you need into one table.
https://docs.microsoft.com/dax/lookupvalue-function-dax
In the case of the Measure I did, Currency, Period, and Methods need to appear in a table for easy filtering.
If possible, I still hope you can provide simple PBIX files for testing, which can remove sensitive data in advance.
Best Regards,
Community Support Team _Charlotte
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
- Birinder4 years ago
Helper III
In the case of the Measure I did, Currency, Period, and Methods need to appear in a table for easy filtering.
Yes,yes. You are finally getting there. I also have the same IDEA of doing so.
If possible, I still hope you can provide simple PBIX files for testing, which can remove sensitive data in advance.
I do want to but data is live, I dont have any permission to remove the data. I dont even know how to create a dummy dimension data. Sorry buddy.
I thought LOOKUP VALUE will work. But as soon as I fill the information of one dimension, only fields for those dimension appears. I can't select any other table from different dimension.