Forum Discussion
DAX expression ignoring blanks statement when extra filter is added
- 6 months ago
Hi gbaia ,
if you need the relationships for some other reasons, try the following:
- Remove all filters from your two date dimensions in both measures
- Change the check for blank values a little bit (EDIT: Maybe it was a bit late yesterday evening, today the solution works without this extra change. So give it a try with just removing the filters...)
The result are the following two measures:
TotalClient2 =VAR _MaxOpenedDate = MAX(OpenDateTable[Date])VAR _MinClosedDate = MIN(CloseDateTable[Date])VAR _result = CALCULATE(DISTINCTCOUNT('cases'[Client_ID]),REMOVEFILTERS(CloseDateTable), REMOVEFILTERS(OpenDateTable),('cases'[date closed] > _MinClosedDate || ISBLANK('cases'[date closed]))&& ('cases'[date opened] <= _MaxOpenedDate))RETURN_resultTotalNewClient2 =VAR _MaxOpenedDate = MAX(OpenDateTable[Date])VAR _MinClosedDate = MIN(CloseDateTable[Date])VAR _result = CALCULATE(DISTINCTCOUNT('cases'[Client_ID]),REMOVEFILTERS(CloseDateTable), REMOVEFILTERS(OpenDateTable),('cases'[date closed] > _MinClosedDate) || (NOT(ISDATETIME( 'cases'[date closed])))&& ('cases'[date opened] <= _MaxOpenedDate)&& ('cases'[date opened] >= _MinClosedDate))RETURN_resultTo be honest I can not explain instantly why the second change is necessary but it seems to work.Hope that this is a working solution for your issue.
FBergamaschi thank you. The SELECTEDVALUE(CloseDateTable[Date]) is the slicer so I can't remove the selected value and if I put MAX, I'll get the same result. It was painful to get that first DAX to work as Power BI doesn't seem to like blank values being added in additional to other filtering conditions, but it worked fine on the first one.
Just adding that additional clause is proving impossible as it just removes the blanks!
Thank you so much and I'll take a look at your content, thanks 🙂
Hi gbaia there is surely a solution, if you can pass me the pbix file I can look into that
via private message in case you cannot share it here
If this helped, please consider giving kudos and mark as a solution
@me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI