Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

Problem with the MEDIAN()

Hi, 

I am creating the equivalent of the SQL Query in POWER BI
SQL QUERY:

ROUND(MEDIAN(CASE WHEN CHALLENGERESULT = 'ABC' AND PRIORPRICE <> 0 AND CREATEDTIMESTAMP BETWEEN TRUNC(TO_DATE('26-JAN-2019','DD-MON-YYYY'))-8
AND TRUNC(TO_DATE('26-JAN-2019','DD-MON-YYYY')) THEN ((ABS(POSTPRICE-PRIORPRICE))/PRIORPRICE)*100 ELSE NULL END),2) "W % Adjustment Magnitude"

DAX:

ROUND(MEDIAN(CALCULATE(COUNTROWS(TABLE),FILTER(TABLE,TABLE[CHALLENGERESULT] = "ABC" && TABLE[PRIORPRICE]<> 0 && TABLE[CREATEDTIMESTAMP].[Date] >= ( SELECTEDVALUE('DATE TABLE'[Date] ) - W_NO_DAYS ) && TABLE[CREATEDTIMESTAMP].[Date] < (SELECTEDVALUE('DATE TABLE'[Date]) - W_NO_DAYS ) + W_NO_DAYS ))),2)

But getting the error "The MEDIAN function only accepts a column reference as the arguement number 1 "
How to solve this issue ?
can somebody please help ?

Thanks !

3 Replies