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

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.

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
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.

Top Solution Authors