Forum Discussion

johnsmith92's avatar
johnsmith92
Regular Visitor
4 years ago
Solved

Translate SQL WHERE clauses to a query

Hi all! I have a very simple model with 2 tables - one fact with cases and history and one date dimension in SSAS. I need a measure to count open cases at the start of each contextualized period. So for example:

DateOpen cases start of day
01-01-202113400
02-02-202113230
03-02-202113300

 

Now, I can achieve this PER day in MSSQL with the following query:

 

 

DECLARE @FilterDate AS DATE;
SET @FilterDate = '2021-01-01'

Select COUNT(*)
FROM FactTable
WHERE TaskCompleted IS NULL
AND IsDeleted = 0
AND DW_ValidFrom < @FilterDate
AND DW_ValidTo >= @FilterDate

 

In SQL I can create a function that reiterates all of the dates needed for my date variable so I would get the table above. In my tabular model I have a 1:* relationship from DimDate to FactCases on DateKey to DW_ValidFrom

 

Could someone help me translate this seemingly easy query to a DAX statement?

  • amitchandak's avatar
    amitchandak
    4 years ago

    johnsmith92 , if you do not have an active join between two tables then you do not need a crossfilter. Make both join inactive

8 Replies