cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
BlueWhite111
Post Patron
Post Patron

TRICY - DAX Measure Error

Hi Experts

 

I cannot work out why the following correlation Coefficent measure are going wrong - All my other Correlation Coeffient Measure work just Fine the following one the sample file - It not having it.

Measure

RME-FAME0 Spread/Soybean Oil 90-Day Rolling = 
VAR NumberOfDays = 90
VAR MaxWorkingDay = MAX ( 'Dimdate'[Working Day Number] )
VAR MinWorkingDay = MaxWorkingDay - ( NumberOfDays - 1 )
VAR DimdatesToUse = 
    FILTER (
        ALL ( 'Dimdate' ),
        AND (
            'Dimdate'[Working Day Number] <= MaxWorkingDay,
            'Dimdate'[Working Day Number] >= MinWorkingDay
        )
    )
VAR Result = 
    CALCULATE (
        DIVIDE ( [Correlation Coefficent 7], NumberOfDays ),
        DimdatesToUse
    )
RETURN
    Result*90

 

Error Message

BlueWhite111_0-1679846291737.png

 

 

Sample File - Data
https://www.dropbox.com/s/vzt3cqk5w9x5b3m/TestData.pbix?dl=0 

6 REPLIES 6
v-yueyunzh-msft
Community Support
Community Support

Hi , @BlueWhite111 

Thanks for your sample data you provide. The dax code for this [Correlation Coefficent 7] seems a measure.

You can try to use this code:

RME-FAME0 Spread/Soybean Oil 90-Day Rolling 2 = 
VAR NumberOfDays = 90
VAR MaxWorkingDay = MAX ( 'Dimdate'[Working Day Number] )
VAR MinWorkingDay = MaxWorkingDay - ( NumberOfDays - 1 )
VAR DimdatesToUse =
FILTER (
ALL ( 'Dimdate' ),
AND (
'Dimdate'[Working Day Number] <= MaxWorkingDay,
'Dimdate'[Working Day Number] >= MinWorkingDay
)
)
VAR CorrelationCoeff = [Correlation Coefficent 7]
VAR Result =
CALCULATE (
DIVIDE ( CorrelationCoeff, NumberOfDays ),
DimdatesToUse
)
RETURN
Result * 90

 

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

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

 

Hi Aniya - can you kindly provide PBIX - slightly confused here. Thanks

Hi, @BlueWhite111 

I just modify the dax here in your measure:

vyueyunzhmsft_0-1679998907552.png

This can resovle the issue , but it put in the visual it will return null due to the [Correlation Coefficent 7] returns null in this visual , you need to check this measures's logic when the filter context is put in this visual.

vyueyunzhmsft_1-1679998999336.png

 

 

Best Regards,

Aniya Zhang

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

Error Message}

BlueWhite111_0-1680011028077.png

 

Hi Aniya the measure errors when you add the measure to a standard table based on the date coming from BIODIESEL table

 

this is my final measure

FAME0 90-Day Volatility STDev = CALCULATE([RME-FAME0 Spread/Soybean Oil 90-Day Rolling 2], Window(94,ABS,0,REL, ALLSELECTED('DimDate'[Date]) , ORDERBY('DimDate'[Date],asc)))

 

Hi Support 

 

Is your code a calculated column measure?

Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors