Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago
Solved

How add moving horizontal line in graph?

Hi,

 

I want to have certain periods of time marked in my chart based on certain events happening during a certain period. I have data from various countries and amount of tourists per month. I want to show whether a decline in tourism can be explained by a certain event in that period. A country can have multiple events. I tried to accomplish this by adding the following measure to my graph:

 

DeseaseLine = IF(max('Tourism'[Year]) = MAX(Event[Year]); 10; blank()
 
This works but as it uses the max function it only shows one line. What I need is : IF('Tourism'[Year]) = Event[Year]); 10; blank(), showing multiple horizontal lines based on the events a country had. However this does not work without including the max function. Anyone has an idea how I can make this work?
 
Thanks in advance!
  • Hi Anonymous ,

     

    "What I need is : IF('Tourism'[Year]) = Event[Year]); 10; blank(), showing multiple horizontal lines based on the events a country had. "

    You can do like this:

    // Creaet column in Tourism table
    Column = 
    VAR x = 
    LOOKUPVALUE(
        Event[Year],
        Event[Year], Tourism[Year]
    )
    RETURN
    IF(
        [Year] = x,
        10, BLANK()
    )

     

    Best regards,
    Lionel Chen

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

5 Replies

  • Anonymous , difficult to say without data. Please explain with an example

    Can you share sample data and sample output.

  • v-lionel-msft's avatar
    v-lionel-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    "What I need is : IF('Tourism'[Year]) = Event[Year]); 10; blank(), showing multiple horizontal lines based on the events a country had. "

    You can do like this:

    // Creaet column in Tourism table
    Column = 
    VAR x = 
    LOOKUPVALUE(
        Event[Year],
        Event[Year], Tourism[Year]
    )
    RETURN
    IF(
        [Year] = x,
        10, BLANK()
    )

     

    Best regards,
    Lionel Chen

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

  • v-lionel-msft's avatar
    v-lionel-msft
    Icon for Community Support rankCommunity Support

    Hi Anonymous ,

     

    Has your problem been solved? 

     

    Best regards,
    Lionel Chen

    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

      yes, thank you!!

    • Anonymous's avatar
      Anonymous
      Not applicable

      yes thank you!