Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
5 years ago
Solved

Calulate open items from Previous month B/Forward

Hi Experts

 

My relationship between my Dim_Date Table and FACT table is based on Date and Created Date (FACT Table)

 

I am trying to work out how many items remained open in the previous periods that have been carried forward to the current period.

 

The following DAX gives me the Difference of applying the Relationship Between the created date and closed date..

ie. Date to Closing Date = 4,186

Date to Created Date -= 2,983

Difference is 1,203....but i need to show the 2,983 in my end result.....TOTALLY STUCK

CALCULATE(COUNT('STG Fact_To_Do'[Closed]),
FILTER('STG Fact_To_Do',
'STG Fact_To_Do'[Created_Date] <= CALCULATE(MAX('STG Dim_Date'[FirstDayOfMonth])) &&
'STG Fact_To_Do'[Date_Closed] >= CALCULATE(MIN('STG Dim_Date'[FirstDayOfMonth]))))
 

Created Date All Dates Before 01.09.2020 
Closed Date is on or after 01.09.2020 

I have applied a month filter from the date table - when i select  Sept  i would expect to see the following results.

Created_DateClosedDate_ClosedFruit
14 August 2020103-Sep-20Apples
10 August 2020107-Sep-20Apples
23 July 2020117-Sep-20Apples
19 August 2020108-Sep-20Apples
11 August 2020102-Sep-20Apples
28 July 2020103-Sep-20Apples
03 April 2020102-Sep-20Apples
22 November 2019108-Sep-20Apples
20 August 2020101-Sep-20Apples
20 August 2020104-Sep-20Apples
17 August 2020107-Sep-20Apples
17 August 2020101-Sep-20Apples
17 August 2020109-Sep-20Apples
11 October 2019115-Sep-20Apples
05 August 2020102-Sep-20Apples
25 August 2020101-Sep-20Banana
17 August 2020103-Sep-20Banana
28 August 2020107-Sep-20Banana
25 August 2020104-Sep-20Banana
17 August 2020109-Sep-20Banana
28 August 2020104-Sep-20Banana
21 August 2020104-Sep-20Banana
17 August 2020104-Sep-20Banana
31 August 2020101-Sep-20Banana
31 August 2020101-Sep-20Banana
31 August 2020101-Sep-20Banana
29 August 2020101-Sep-20Banana
31 August 2020101-Sep-20Banana
31 August 2020101-Sep-20Banana
31 August 2020101-Sep-20Banana
31 August 2020101-Sep-20Banana
26 August 2020101-Sep-20Banana
27 August 2020109-Sep-20Banana
27 August 2020109-Sep-20Banana
27 August 2020109-Sep-20Banana
26 August 2020109-Sep-20Banana
25 August 2020101-Sep-20Banana
21 August 2020101-Sep-20Oranges
21 August 2020101-Sep-20Oranges
20 August 2020101-Sep-20Oranges
26 August 2020109-Sep-20Oranges
25 August 2020101-Sep-20Oranges
19 August 2020101-Sep-20Oranges
24 August 2020101-Sep-20Oranges
24 August 2020101-Sep-20Oranges
24 August 2020103-Sep-20Oranges
12 August 2020117-Sep-20Oranges
27 August 2020114-Sep-20Oranges
28 August 2020110-Sep-20Oranges
28 August 2020117-Sep-20Oranges
25 August 2020101-Sep-20Oranges
28 August 2020102-Sep-20Oranges
28 August 2020102-Sep-20Oranges
24 August 2020108-Sep-20Oranges
24 August 2020103-Sep-20Oranges
19 August 2020107-Sep-20Oranges
18 August 2020104-Sep-20Oranges
28 August 2020101-Sep-20Oranges
20 August 2020104-Sep-20Oranges
20 August 2020101-Sep-20Oranges
20 August 2020114-Sep-20Oranges
25 June 2020102-Sep-20Oranges
28 August 2020104-Sep-20Oranges
13 August 2020102-Sep-20Oranges
25 August 2020109-Sep-20Oranges
13 August 2020109-Sep-20Oranges
27 August 2020102-Sep-20Oranges
27 August 2020104-Sep-20Oranges
21 August 2020110-Sep-20Oranges
19 August 2020111-Sep-20Oranges
12 August 2020109-Sep-20Oranges
03 August 2020109-Sep-20Oranges
19 August 2020102-Sep-20Oranges
18 August 2020101-Sep-20Oranges
06 July 2020108-Sep-20Oranges
03 July 2020104-Sep-20Oranges
24 August 2020104-Sep-20Oranges
18 August 2020109-Sep-20Oranges
27 August 2020104-Sep-20Oranges
26 August 2020102-Sep-20Oranges
24 August 2020107-Sep-20Oranges
17 August 2020109-Sep-20Oranges
13 August 2020104-Sep-20Oranges
26 August 2020102-Sep-20Oranges
21 July 2020101-Sep-20Oranges
16 July 2020104-Sep-20Oranges
24 August 2020102-Sep-20Oranges
04 September 2019115-Sep-20Oranges
25 August 2020101-Sep-20Oranges
02 December 2019104-Sep-20Oranges
25 August 2020115-Sep-20Oranges
28 August 2020117-Sep-20Oranges
28 August 2020117-Sep-20Oranges
28 August 2020117-Sep-20Oranges
21 August 2020112-Sep-20Oranges
14 May 2020110-Sep-20Oranges
24 August 2020101-Sep-20Oranges
24 August 2020101-Sep-20Oranges
27 August 2020109-Sep-20Oranges
  • Anonymous's avatar
    Anonymous
    5 years ago

    Hi Anonymous ,

    It seems like you want to calculate the count within the selected date period. You could use the following formula with Slicer :

    count =
    VAR _min =
        MIN ( 'DateSlicer'[Date] )
    VAR _max =
        MAX ( 'DateSlicer'[Date] )
    RETURN
        CALCULATE (
            COUNT ( 'STG Fact_To_Do'[Closed] ),
            FILTER (
                'STG Fact_To_Do',
                'STG Fact_To_Do'[Created_Date] <= _max
                    && 'STG Fact_To_Do'[Date_Closed] >= _min
            )
        )

    Did I answer your question ? Please mark my reply as solution. Thank you very much.

    If not, please upload some insensitive data samples and expected output.

     

    Best Regards,

    Eyelyn Qin

4 Replies

  • Anonymous , Prefer date is coming from an independent date slicer

    Measure =
    var _min = minx(allselected(Date), Date[Date])
    return
    calculate(countrows([Table]), filter(Table, Table[Created_Date]<_min && Table[Created_Date]>=_min))

     

    or

     

    Measure =
    var _min = minx(allselected(Date), Date[Date])
    return
    calculate(countrows([Table]), filter(all(Table), Table[Created_Date]<_min && Table[Created_Date]>=_min))




  • AllisonKennedy's avatar
    AllisonKennedy
    Icon for Community Champion rankCommunity Champion
    Anonymous
    Also try changing relationship to use Closed Date instead of Created Date (or create a new measure using the USERELATIONSHIP if you want the created date filter in other areas of your report).
    Based on your explanation, it seems like you want to filter the DimDate[Date] and get a list of all items that have been closed in that time period, so the relationship needs to be for Closed Date to make this work, otherwise you won't see any items that were created in other periods. Does that make sense?
    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Allison 

       

      How would you write the dax using user relationships in the measure based on date closed and date filed from Dim Date.

       

      count =
      VAR _min =
          MIN ( 'DateSlicer'[Date] )
      VAR _max =
          MAX ( 'DateSlicer'[Date] )
      RETURN
          CALCULATE (
              COUNT ( 'STG Fact_To_Do'[Closed] ),
              FILTER (
                  'STG Fact_To_Do',
                  'STG Fact_To_Do'[Created_Date] <= _max
                      && 'STG Fact_To_Do'[Date_Closed] >= _min
              )
          )

       

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    It seems like you want to calculate the count within the selected date period. You could use the following formula with Slicer :

    count =
    VAR _min =
        MIN ( 'DateSlicer'[Date] )
    VAR _max =
        MAX ( 'DateSlicer'[Date] )
    RETURN
        CALCULATE (
            COUNT ( 'STG Fact_To_Do'[Closed] ),
            FILTER (
                'STG Fact_To_Do',
                'STG Fact_To_Do'[Created_Date] <= _max
                    && 'STG Fact_To_Do'[Date_Closed] >= _min
            )
        )

    Did I answer your question ? Please mark my reply as solution. Thank you very much.

    If not, please upload some insensitive data samples and expected output.

     

    Best Regards,

    Eyelyn Qin