Forum Discussion

Uniqueusername's avatar
Uniqueusername
Icon for Helper III rankHelper III
2 years ago
Solved

Adventure Works 2020 Model - blank dates DAX filter context

Hi all,

 

I am trying to understand more about filter contexts in DAX. For this, I have downloaded the Adventure 2020 model from this link https://learn.microsoft.com/en-us/dax/dax-sample-model

I started with creating a a simple matrix visual with "Year" on the rows and a measure "Number of dates in range" which calculates the maximum visible date in the values field

When I do this I am seeing one row in the visual where the year is blank. I am trying to figure out what is causing this. I had a few sales related measures in the visual initally. First thought was there there could be sales in the sales table which do not have a corresponding "order date" in the date table. Removing those sales related measures didn't do anything as I can still see those blank values

Hopefully, the screenshot below might help

 

I also added year slicer. Now this year slicer shows a blank value for some reason. I checked the date table but couldn't find anything

 

Here is the measure I created

 

 

 

Number of dates in range = 
VAR LastdateinContext =
   MAX('Date'[date])
VAR DatesinRange =
    FILTER ( 'Date', 'Date'[Date] <= LastdateinContext )
VAR AllDates =all('Date'[Year])

RETURN
    COUNTROWS(AllDates)

 

 

 


I am sure I am missing something very obvious. But I'm just not able to figure out what that is. I looked at the model to check if there are any odd looking dates in the tables that should not be there but have not been able to find anything

Any help will be much appreciated!

 

Thank you

5 Replies

  • talespin 

    Thanks for that ! Removing the inactive relationships fixed it. But I don't know what is driving that behaviour. I also tried to check for dirty data like in the video you have linked to but couldn't find anything standing out

    How would you avoid these blanks in a situation where you certainly require an inactive relationship ?

    Thanks

    • talespin's avatar
      talespin
      Icon for Solution Sage rankSolution Sage

      hi Uniqueusername ,

       

      In case its a data issue, you should include blanks.

       

      Otherwise you can just apply filter from filter panel to exclude blanks.

  • I found the culprit. The shipdatekey in the Sales table has blanks. I didn't know inactive relationships on columns with blanks can cause blanks to appear like that