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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
bolabuga
Helper V
Helper V

[ using advanced setfilter ]

Hello everyone, 

 

here is the pbix file: https://drive.google.com/open?id=0B8Aq8DhGApJqa0stb2szM2dBTUU

 

Im reading the "Definitive Guide to DAX" and im failing to understand a explame on chapter 10, that have the name used on the post subject.

 

The objective is to count the open contracts each filtered date and the book start by creating 2 measures:

 

FIRSTDATE = 
IF(
	ISCROSSFILTERED('DATE'[Date]);
	MIN('DATE'[Date]);
	DATE(2015;2;17))

LASTDATE = 
IF(
	ISCROSSFILTERED('DATE'[Date]);
	MAX('DATE'[Date]);
	DATE(2015;2;17))

Those 2 measures will be seeing the same date for firstdate and lastdate measures and will be used on the OPENCONTRACTS measure, where the number of open contracts will be counted.

 

OPENCONTRACTS V1 = 
SUMX (
FILTER (
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZE (
CONTRACTS;
Contracts[StartDate];
Contracts[EndDate]);
"NumOfOrders";
CALCULATE( COUNTROWS ( Contracts ) )
);
ALL ( 'Date' )
);
AND (
Contracts[StartDate] <= [FirstDate];
Contracts[EndDate] >= [LastDate]
)
);
[NumOfOrders]
)

Ok, for my doubt:

 

Why is the proposed solution on the book using firstdate and lastdate?? i have tested 2 measures (opencontracts v3 and v4) using just [TESTDATEmax] and the results are the same.

 

TESTDATEmax = IF(ISCROSSFILTERED('DATE'[Date]);MAX('DATE'[Date]);DATE(2015;2;17)) 

1 ACCEPTED SOLUTION
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @bolabuga,

Based on my understanding, the firstdate and lastdate measures get the current Date[date] , then you can use it in other measure. For example, you use them as part of another measure as follows.

AND ( 
       Contracts[StartDate] <= [FirstDate];
       Contracts[EndDate] >= [LastDate]
       )


If you don't create measure to get the date, you are unable to use Date[date] directly, it will use one value in the place.

Best Regards,
Angelia 

View solution in original post

2 REPLIES 2
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @bolabuga,

Based on my understanding, the firstdate and lastdate measures get the current Date[date] , then you can use it in other measure. For example, you use them as part of another measure as follows.

AND ( 
       Contracts[StartDate] <= [FirstDate];
       Contracts[EndDate] >= [LastDate]
       )


If you don't create measure to get the date, you are unable to use Date[date] directly, it will use one value in the place.

Best Regards,
Angelia 

@v-huizhn-msft

 

firstdate and lastdate get the current date (which is the same date in this example), and i thought i might be understanding something wrong or not seeing another use of those measures. But in this example i could use just firstdate for example and get the same result. 

 

Thanks for the confirmation.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

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.