March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early bird discount ends December 31.
Register NowBe one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now
Please help to calculate/understand properly lastDate and rankDate measures for following simplified example (download) :
Desired result:
Reality (incorrect subtypes):
Why relationship is broken?
How to avoid this cartesian product lines?
My Measure (I commented workaround, because it's kind of postfilter, not prefilter):
rnkDate = VAR t = CALCULATETABLE( VALUES(tstTable[Date]), REMOVEFILTERS(tstTable[Date]) ) RETURN //IF( MAX(tstTable[Amount])<>BLANK(), // WORKAROUND To hide unwantedd rows RANKX( t, LASTDATE(tstTable[Date]) ) //)
P.S. Mess happens only if I use fields from dimensional table dimType[Type] (within one table everything is Ok):
@tamerj1 , thank you for your feedback.
@Anonymous
1. Yes you are right.
2. The issue is related to the filter context. One column of the fact table (the [Date] column) is used in the matrix therefore, it's part of the filter context. In this case the filter context created by the engine is the CROSSJOIN between the SUMMARIZE ( dimType, dimType[Type], dimType[subType] ) and DISTINCT ( tstTable[Date] ) which generates all the possible combinations between the two tables.
When placing a normal aggregation measure in the matrix the engine checks first if the value is blank then it hides it. With RANKX things are different and the reason is that even the balnk value will have a rank (because DAX considers blank as zero in calculations) and the rank cannot be blank rather it will be the samllest or the largest rank value depending on the sort oreder of RANKX.
3. You can upload to DropBox or OneDrive and share the download link.
Hi @Anonymous
Please refer to attached sample file with the solution
lastDate =
CALCULATE (
LASTDATE ( tstTable[Date] ),
REMOVEFILTERS ( tstTable[Date] ),
CROSSFILTER ( tstTable[subType], dimType[subType], BOTH )
)
rnkDate =
VAR t =
CALCULATETABLE (
VALUES ( tstTable[Date] ),
REMOVEFILTERS ( tstTable[Date] )
)
VAR Result =
RANKX(
t,
CALCULATE ( MAX ( tstTable[Date] ) )
)
RETURN
IF (
NOT ISEMPTY ( tstTable ),
Result
)
March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!
Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.
User | Count |
---|---|
21 | |
14 | |
11 | |
8 | |
5 |
User | Count |
---|---|
28 | |
21 | |
20 | |
13 | |
10 |