Forum Discussion
svishwanathan
7 years agoHelper III
Dax help-using variables
Hi I want to create a measure that adds the sales in a given period. There is a column in the sales/actuals table called #Day which is a lookup from my calendar table. This column contains a uniq...
- 7 years ago
Hi svishwanathan,
The Segment table should be independent of other tables, which means no relationship can be established. And also try to wrap Actuals with ALL like below.
ActualsSegment = VAR lowerlimit = IF ( HASONEVALUE ( 'Segment'[Segment] ), VALUES ( 'Segment'[Min] ), BLANK () ) VAR higherlimit = IF ( HASONEVALUE ( 'Segment'[Segment] ), VALUES ( 'Segment'[Max] ), BLANK () ) RETURN CALCULATE ( [Actuals], FILTER ( ALL ( Actuals[#Day] ), Actuals[#Day] >= lowerlimit && Actuals[#Day] <= higherlimit ) )Best Regards,
Dale
v-jiascu-msft
7 years agoMicrosoft Employee
Hi svishwanathan,
The Segment table should be independent of other tables, which means no relationship can be established. And also try to wrap Actuals with ALL like below.
ActualsSegment =
VAR lowerlimit =
IF ( HASONEVALUE ( 'Segment'[Segment] ), VALUES ( 'Segment'[Min] ), BLANK () )
VAR higherlimit =
IF ( HASONEVALUE ( 'Segment'[Segment] ), VALUES ( 'Segment'[Max] ), BLANK () )
RETURN
CALCULATE (
[Actuals],
FILTER (
ALL ( Actuals[#Day] ),
Actuals[#Day] >= lowerlimit
&& Actuals[#Day] <= higherlimit
)
)
Best Regards,
Dale