Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Average Between Three Dates Versus Main Date

I am creating a dashboard to show the days between(Lag) the latest of three different date columns versus the main date(Physical Date) column. Now I need to find the average days between those three...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous 

     

    Maybe you can try this:
    I added some date into the sample data to test:

    Then add 3 calculate columns to get the Datediff of the 3 type date,like this:

    Then i create a table:

    And a measure:

    Lag1 = 
    VAR _aveValue = SELECTEDVALUE('Table'[Value])
    	VAR result = SWITCH(
    		_aveValue,
    		"ave_sDate", CALCULATE(
    			SUM('Table (2)'[SDATE]) / COUNTROWS('Table (2)'),
    			FILTER(
    				ALLSELECTED('Table (2)'),
    				'Table (2)'[Submission Date] <> BLANK()
    			)
    		),
    //Get the average of the sum of the datediff from physical date to submission Date
    		"ave_paDate", CALCULATE(
    			SUM('Table (2)'[PADATE]) / COUNTROWS('Table (2)'),
    			FILTER(
    				ALLSELECTED('Table (2)'),
    				'Table (2)'[Price Approved Date] <> BLANK()
    			)
    		),
    		"ave_taDate", CALCULATE(
    			SUM('Table (2)'[TADATE]) / COUNTROWS('Table (2)'),
    			FILTER(
    				ALLSELECTED('Table (2)'),
    				'Table (2)'[Terms Approved Date] <> BLANK()
    			)
    		)
    	)
    	RETURN
    		result

     

    The result is as follow:

     

    Best Regards,

    Zhengdong Xu

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.