Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

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

 

 

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

6 Replies

  • Hi , Anonymous 

    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

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi Support 

       

      Is your code a calculated column measure?

    • Anonymous's avatar
      Anonymous
      Not applicable

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

      • v-yueyunzh-msft's avatar
        v-yueyunzh-msft
        Community Support

        Hi, Anonymous 

        I just modify the dax here in your measure:

        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.

         

         

        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