Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
7 years ago
Solved

Display Month-wise and YTD data in one visual

Hi Guys,

 

I am trying to display month-wise and  YTD data in one visual, which I am not able to do it now. Is there any provision to do this in Power BI?

I have attached a sample snapshot with this, that I want to achieve in power BI. Please suggest any visual if any or DAX.

Sample graph

  • Hi Anonymous ,

     

    Please check the following steps as below.

     

    1. Create a calculated table and relat it to the fact table like this.

    YM = UNION(VALUES('Table'[Year]),VALUES('Table'[Month]))

     

    2. Then we can create a measure to get the excepted result as we need.

     

    Measure = var a = SUM('Table'[value])
    return
    IF(ISBLANK(a),CALCULATE(SUM('Table'[value]),USERELATIONSHIP('Table'[Year],YM[Year])),a)

     

    For more details, please check the pbix as attached.

     

8 Replies

  • I don't get your question.

     

    Put the "YEAR" in the Legend dimension

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

    Hi Anonymous ,

     

    Please check the following steps as below.

     

    1. Create a calculated table and relat it to the fact table like this.

    YM = UNION(VALUES('Table'[Year]),VALUES('Table'[Month]))

     

    2. Then we can create a measure to get the excepted result as we need.

     

    Measure = var a = SUM('Table'[value])
    return
    IF(ISBLANK(a),CALCULATE(SUM('Table'[value]),USERELATIONSHIP('Table'[Year],YM[Year])),a)

     

    For more details, please check the pbix as attached.

     

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thank you for the solution. It worked for me.

    • Caballero's avatar
      Caballero
      Frequent Visitor

       

      This solution works excellent, How i can sort the months chronologically? Jan, Feb, Mar, Apr, .........YTD

       

      tks.

       

    • Anonymous's avatar
      Anonymous
      Not applicable

      Thanks

      We have already used that DAX, but it is not working.

      What I want is one bar for past year and for this year(i.e 2019), the graph should show month-wise, this both(past year and 2019 month-wise) in one graph as shown in the screenshot.

       

      • Anonymous's avatar
        Anonymous
        Not applicable

         

        I am able to do it in excel, need solution to implement same in Power BI