Forum Discussion
DDL1976
5 years agoFrequent Visitor
DAX Filter Problem
I am new to the wqorld of DAX and Power BI... I have created the following 2 measures but they dont work... CFY = LOOKUPVALUE(DimPeriod[Financial Year], DimPeriod[Period End Date], LASTDATE(Dim...
- 5 years ago
DDL1976 The former isn't working due to a mechanism know as "Context Transition", pretty sophisticated thing but you will get a hang of it soon.
For now write your code like this:
AC = VAR CurrentFinancialYear = [CFY] VAR DateFilter = FILTER ( DimPeriod, DimPeriod[Financial Year] = CurrentFinancialYear ) VAR Result = CALCULATE ( SUM ( FactTransactionLine[Value] ), DateFilter ) RETURN ResultAnd once you are comfortable with DAX write it like this:
AC = VAR CurrentFinancialYear = [CFY] VAR Result = CALCULATE ( SUM ( FactTransactionLine[Value] ), KEEPFILTERS ( DimPeriod[Financial Year] = CurrentFinancialYear ) ) RETURN Result
AntrikshSharma
Community Champion
5 years agoDDL1976 The former isn't working due to a mechanism know as "Context Transition", pretty sophisticated thing but you will get a hang of it soon.
For now write your code like this:
AC =
VAR CurrentFinancialYear = [CFY]
VAR DateFilter =
FILTER ( DimPeriod, DimPeriod[Financial Year] = CurrentFinancialYear )
VAR Result =
CALCULATE ( SUM ( FactTransactionLine[Value] ), DateFilter )
RETURN
Result
And once you are comfortable with DAX write it like this:
AC =
VAR CurrentFinancialYear = [CFY]
VAR Result =
CALCULATE (
SUM ( FactTransactionLine[Value] ),
KEEPFILTERS ( DimPeriod[Financial Year] = CurrentFinancialYear )
)
RETURN
Result