Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.
I have written a DAX measure to calculate revenue of past 12 months (TTM), it's not working because the Scenario table is filtered by some slicers, how can I remove the filter on scenario table? Please help update the highlighted part below.
Solved! Go to Solution.
Hi @Jeanxyz
Please try this:
Actual_TTM(M) =
VAR max_year =
CONVERT ( MAX ( Scenario[Scenario Year] ), INTEGER )
VAR max_month =
SELECTEDVALUE ( Period[Period Num] )
VAR max_date =
EOMONTH ( DATE ( max_year, max_month, 1 ), 0 )
VAR min_date =
DATE ( YEAR ( EOMONTH ( max_date, -11 ) ), MONTH ( EOMONTH ( max_date, -11 ) ), 1 )
VAR AggregatedSalesInCurrency =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE (
FILTER (
ALL ( FactTable ),
FactTable[TGK_CALENDAR_KEY] <= max_date
&& FactTable[TGK_CALENDAR_KEY] >= min_date
&& FactTable[Scenario Type Code] = "CONSO"
),
Scenario[Scenario Code],
//how can I remove the filter on scenario table?
'Transaction Currency'[Transaction Currency Code]
),
"@SalesAmount", [Balance Sheet Amount Monthly Converted Monthly Rate],
"@Rate",
CALCULATE (
SELECTEDVALUE ( 'Exchange Rate'[Average Exchange Rate] ),
'Period'[Period Num] = MAX ( 'Period'[Period Num] )
)
),
ALL ( 'Scenario' )
)
RETURN
SUMX (
AggregatedSalesInCurrency,
IF ( NOT ( ISBLANK ( [@Rate] ) ), [@SalesAmount] * [@Rate], BLANK () )
)
The calculatetable() function can use filters on the table.
If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Jeanxyz
Please try this:
Actual_TTM(M) =
VAR max_year =
CONVERT ( MAX ( Scenario[Scenario Year] ), INTEGER )
VAR max_month =
SELECTEDVALUE ( Period[Period Num] )
VAR max_date =
EOMONTH ( DATE ( max_year, max_month, 1 ), 0 )
VAR min_date =
DATE ( YEAR ( EOMONTH ( max_date, -11 ) ), MONTH ( EOMONTH ( max_date, -11 ) ), 1 )
VAR AggregatedSalesInCurrency =
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE (
FILTER (
ALL ( FactTable ),
FactTable[TGK_CALENDAR_KEY] <= max_date
&& FactTable[TGK_CALENDAR_KEY] >= min_date
&& FactTable[Scenario Type Code] = "CONSO"
),
Scenario[Scenario Code],
//how can I remove the filter on scenario table?
'Transaction Currency'[Transaction Currency Code]
),
"@SalesAmount", [Balance Sheet Amount Monthly Converted Monthly Rate],
"@Rate",
CALCULATE (
SELECTEDVALUE ( 'Exchange Rate'[Average Exchange Rate] ),
'Period'[Period Num] = MAX ( 'Period'[Period Num] )
)
),
ALL ( 'Scenario' )
)
RETURN
SUMX (
AggregatedSalesInCurrency,
IF ( NOT ( ISBLANK ( [@Rate] ) ), [@SalesAmount] * [@Rate], BLANK () )
)
The calculatetable() function can use filters on the table.
If the above one can't help you, could you please provide more raw data in your tables (exclude sensitive data) with Text format and your expected result with backend logic and special examples? It would be helpful to find out the solution. You can refer the following links to share the required info:
How to provide sample data in the Power BI Forum
How to Get Your Question Answered Quickly
And It is better if you can share a simplified pbix file. You can refer the following link to upload the file to the community. Thank you.
How to upload PBI in Community
Best Regards
Zhengdong Xu
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
97 | |
95 | |
80 | |
77 | |
66 |
User | Count |
---|---|
129 | |
106 | |
106 | |
86 | |
72 |