Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
3 years ago

USERELATIONSHIP THROWING ERROR

Hello,

Below code throws an error "USERELATIONSHIP function can only use the two columns references participating in relationship."

Cases Last 13 Month =
var MaxDate = MAX('Calendar'[Calendar_last_day_of_month])
var MaxDate_13MonthsAgo = DATESINPERIOD('Presenatation calendar'[Calendar_last_day_of_month],MaxDate, -13,MONTH)
var Results  =  CALCULATE(Actuals_by_Month[Actuals_Volume],
REMOVEFILTERS('Calendar') ,
KEEPFILTERS(MaxDate_13MonthsAgo),
USERELATIONSHIP('Calendar'[Calendar_last_day_of_month],'Presenatation calendar'[Calendar_last_day_of_month]))
RETURN
 Results
 
Notes: I already have inactive relationship established between Calendare table and presentation table
Could someone can tell whats wrong here?
Thanks

4 Replies

  • Anonymous  please Try this formula.

    Cases Last 13 Month =

     

    var MaxDate = CALCULATE(

     MAX('Calendar'[Calendar_last_day_of_month])

    ,USERELATIONSHIP('Calendar'[Calendar_last_day_of_month]

                                   ,'Presenatation calendar'[Calendar_last_day_of_month])

                                  )

     

    var MaxDate_13MonthsAgo =

    DATESINPERIOD(

                                'Presenatation calendar'[Calendar_last_day_of_month]

                                ,MaxDate

                                , -13

                               ,MONTH

                             )

    var Results =

    CALCULATE(

                        Actuals_by_Month[Actuals_Volume],
                        REMOVEFILTERS('Calendar') ,
                        KEEPFILTERS(MaxDate_13MonthsAgo)
    )

     

    RETURN
    Results

     

     

    ** If this post helps, please consider accept as solution to help other members find it more quickly and Appreciate your Kudos.

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you Mahesh0016 , BUT GETTING SAME ERROR.

      • Mahesh0016's avatar
        Mahesh0016
        Super User

        Anonymous Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.