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
kkanda
Resolver II
Resolver II

Use of multiple variables in the same measure

Hi All,

I have gone through the some related posts in this Forum and SQL BI and I wrote the following DAX expression using multiple variables for the measure:

Test_Measure =
Var Res_2 = FILTER('M1 Notifications', ('M1 Notifications'[Created on] < (TODAY()-1825) && 'M1 Notifications'[Created on] > (TODAY()-365))
Var Res_1 = FILTER(Res_2, ('M1 Notifications'[Notification System Status] = "Outstanding notification" || 'M1 Notifications'[Notification System Status] = "Order assigned" || 'M1 Notifications'[Notification System Status] = "Notification in process"))
RETURN
IF(COUNTROWS(Res_1) <> BLANK(),COUNTROWS(Res_1),UNICHAR((32))
)
I used two Variables to filter the same table in succession for different criteria. This is basically an AND filter.
I get a syntax error for Var Res_1. I am not sure how we can use both Variables instead of writing a long Filter expression combining all conditions. For Var Res_1, can I use the filtered table Res_2? I tried using table name in its place but it is still the same error.
I will appreciate if the experts explain how the successive filters can be applied with Variables.
Thank you in advance
Krishna
2 ACCEPTED SOLUTIONS
jdbuchanan71
Super User
Super User

@kkanda 

Your measure was missing a closing parenthisis in the first Var.

Test Measure =
VAR Res_2 =
    FILTER (
        'M1 Notifications',
         (
            'M1 Notifications'[Created on]
                < ( TODAY () - 1825 )
                && 'M1 Notifications'[Created on]
                    > ( TODAY () - 365 )
        )
    )
VAR Res_1 =
    FILTER (
        Res_2,
         ( 'M1 Notifications'[Notification System Status] = "Outstanding notification"
            || 'M1 Notifications'[Notification System Status] = "Order assigned"
            || 'M1 Notifications'[Notification System Status] = "Notification in process" )
    )
RETURN
    IF ( COUNTROWS ( Res_1 ) <> BLANK (), COUNTROWS ( Res_1 ), UNICHAR ( ( 32 ) ) )

View solution in original post

Thanks for the correction. 

View solution in original post

2 REPLIES 2
jdbuchanan71
Super User
Super User

@kkanda 

Your measure was missing a closing parenthisis in the first Var.

Test Measure =
VAR Res_2 =
    FILTER (
        'M1 Notifications',
         (
            'M1 Notifications'[Created on]
                < ( TODAY () - 1825 )
                && 'M1 Notifications'[Created on]
                    > ( TODAY () - 365 )
        )
    )
VAR Res_1 =
    FILTER (
        Res_2,
         ( 'M1 Notifications'[Notification System Status] = "Outstanding notification"
            || 'M1 Notifications'[Notification System Status] = "Order assigned"
            || 'M1 Notifications'[Notification System Status] = "Notification in process" )
    )
RETURN
    IF ( COUNTROWS ( Res_1 ) <> BLANK (), COUNTROWS ( Res_1 ), UNICHAR ( ( 32 ) ) )

Thanks for the correction. 

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