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
Anonymous
Not applicable

Use values of variables to filter data

Hello,

I have 2 variable like as bellow : 

 

Var1 = 	   SUMMARIZE(
				ORDDTS,
				ORDDTS[ID_CUSTOMER]
				, "MINORDER",MIN(ORDDTS[ID_ORDERDATE])
	)
Var2 = 	   SUMMARIZE(
				ORDDTS,
				ORDDTS[ID_CUSTOMER]
				, "MAXORDER",MAX(ORDDTS[ID_ORDERDATE])
	)

 

I want to filter the customer who have MaxOrder-MinOrder>100

 

i did the code as bellow but doesn't work

 

CALCULATE(NATURALINNERJOIN(var1, var2), VALUES('var1'[MINORDER]) - VALUES('var2'[MAXORDER])>100)

 

Any idea how can i do that ?

 

Thanks for help ! 

1 ACCEPTED SOLUTION
tamerj1
Super User
Super User

Hi @Anonymous 

Not sure what exactly are trying to achieve. I guess this is a 100 days difference between first and last orders. Please try

Table1 =
VAR T1 =
    ADDCOLUMNS (
        SUMMARIZE ( ORDDTS, ORDDTS[ID_CUSTOMER] ),
        "@MINORDER", CALCULATE ( MIN ( ORDDTS[ID_ORDERDATE] ) ),
        "@MAXORDER", CALCULATE ( MAX ( ORDDTS[ID_ORDERDATE] ) )
    )
VAR T2 =
    FILTER ( T1, [@MAXORDER] - [@MINORDER] = 100 )
RETURN
    T2

View solution in original post

3 REPLIES 3
tamerj1
Super User
Super User

Hi @Anonymous 

Not sure what exactly are trying to achieve. I guess this is a 100 days difference between first and last orders. Please try

Table1 =
VAR T1 =
    ADDCOLUMNS (
        SUMMARIZE ( ORDDTS, ORDDTS[ID_CUSTOMER] ),
        "@MINORDER", CALCULATE ( MIN ( ORDDTS[ID_ORDERDATE] ) ),
        "@MAXORDER", CALCULATE ( MAX ( ORDDTS[ID_ORDERDATE] ) )
    )
VAR T2 =
    FILTER ( T1, [@MAXORDER] - [@MINORDER] = 100 )
RETURN
    T2
Anonymous
Not applicable

@tamerj1 I want to sperate two variables because the second variable contains others filters

@Anonymous 
Please provide the complete picture otherwise it would be difficult to provide your with proper answer.

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.