Forum Discussion

AnnieV's avatar
AnnieV
Frequent Visitor
1 year ago

two line chart overlay x-axis

I have two line charts I'd like to overlay - both use the same measure calculation for a score, but one is anchored on the "event date" for the year-month buckets, and the second is anchored on the "report date" for the year-month buckets. It is not atypical for an event to have a report date in a later month than the event occured. 

 

Accordingly, the model has two date dimension tables (EventDateDim and ReportDateDim) with the DateKey from EventDateDim related to the EventDateKey on the EventFact, and the DateKey from ReportDateDim related to the ReportDateKey on the EventFact. 

 

Creating individual line charts, the YearMonth buckets are drawn from the respective date dim tables, but I'd like to show both lines together instead of separated as so

4 Replies

  • AnnieV,

     

    I would eliminate one of the date tables so your model has only one date table. Then create two relationships between the date table and EventFact; one of the relationships will be active and one will be inactive. Use the DAX function USERELATIONSHIP to invoke the inactive relationship.

     

    https://dax.guide/userelationship/ 

  • AnnieV's avatar
    AnnieV
    Frequent Visitor

    Hi DataInsights , 

    I've used userelationship in the past, but I'm not making the connection between doing that and being able to have the second line, which uses the same measure as the first? 

    • DataInsights's avatar
      DataInsights
      Icon for Super User rankSuper User

      AnnieV,

       

      Try creating two measures, each with the same logic except one of the measures contains USERELATIONSHIP. This would allow the X-axis to slice each measure using the appropriate date field (event date or report date).

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi, AnnieV 

    Have you solved your problem? If so, can you share your solution here and mark the correct answer as a standard answer to help other members find it faster? Thank you very much for your kind cooperation!

     

    Best Regards

    Yongkang Hua.