Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Calculate count between two dates

Hi ,

 

I have three tables  fact table, sprint table.

 

Fac Table

 

Fact
IDBuildStatDateTriageStartDate
12110-11-202311-11-2023
12211-12-202312-11-2023
12312-12-202313-12-2023
12413-12-202314-12-2023
12514-12-202315-12-2023
12615-12-202316-12-2023
12716-12-202317-12-2023

 

Sprint 
Sprint StartEnd
Nov01-11-202330-11-2023
Dec01-12-202331-12-2023

 

Write dax to  Count id when Build Start date and  Triage Start date falls between Sprint Start date and End Date using calndar table .Expected Outcome will be:

 

SprintCount based on Build Start DateCount based on Triage Start Date
Nov12
Dec65
Total77
  • Hi Anonymous 

     

    Would a measure like this help?

    Build = 
    VAR _SoM = SELECTEDVALUE( 'Sprint'[Start] )
    VAR _EoM = SELECTEDVALUE( 'Sprint'[End] )
    VAR _Count =
        COUNTROWS(
            FILTER(
                ALLSELECTED( 'FactTable'[BuildStatDate] ),
                'FactTable'[BuildStatDate] >= _SoM
                    && 'FactTable'[BuildStatDate] <= _EoM
            )
        )
    RETURN
        _Count

     

    Counts for Build and Triage.pbix

     

4 Replies

  • Hi Anonymous 

     

    Would a measure like this help?

    Build = 
    VAR _SoM = SELECTEDVALUE( 'Sprint'[Start] )
    VAR _EoM = SELECTEDVALUE( 'Sprint'[End] )
    VAR _Count =
        COUNTROWS(
            FILTER(
                ALLSELECTED( 'FactTable'[BuildStatDate] ),
                'FactTable'[BuildStatDate] >= _SoM
                    && 'FactTable'[BuildStatDate] <= _EoM
            )
        )
    RETURN
        _Count

     

    Counts for Build and Triage.pbix

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks , just wanted to check how we can implment this using calendar table.Because i need calendar table which filter both Build and Triage.

      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        For all practical purposes, the Sprint table is the Calendar table.  It should just have 3 columns - Date, Month name and Month number.  Sort the Month name by the Month number.  there shouldnot be a relationship between Calendar Table and the other 2 tables.