Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
Jeanxyz
Power Participant
Power Participant

how to remove filters in a virtual table

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.

 

 

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 =
    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])
        )
    )
return
SUMX(
        AggregatedSalesInCurrency,
        IF(
            NOT(ISBLANK([@Rate])),
            [@SalesAmount] * [@Rate],
            BLANK()
        )
    )
1 ACCEPTED SOLUTION
Anonymous
Not applicable

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.

 

View solution in original post

1 REPLY 1
Anonymous
Not applicable

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.

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors