Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

To Summarize table to display into stacked chart

Hi ,

I have been struggling ....I have my data with sum of total for all the stages : 

1) Current Spend

2) Project

3) Budget

and I hope to stack by region (2nd image) and , i could do it in excel... but in powerBi, I have been struggling as i am still not used to DAX language... I read on Summarized, but keep getting errors on the DAX codes... thus, hope to get advise from the forum.

 

Looking forward to your kind advise, Thanks, Val 

 

 

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi Anonymous ,

    If your table data looks like this.I don't think there is any need to add Qtr.

    All you need to do is add the field to the visual and it will filter the data accordingly.

     

    Best Regards,
    Wenbin Zhou

  • Anonymous's avatar
    Anonymous
    2 years ago

    Dear @Wenbin Zhou,

     

    it's works for one of my data models 🙂

    I shall look into my other to see where could go wrong then. Many thanks for your kind help, the extremely helpful tips, great enlightenment for me.

     

    Cheers, Val 

4 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi Anonymous ,

    If I understand it wrong, please provide simple data.

     

    Regarding your question, if your data is similar to what I assume, I don't think you need to use the 'Summarize' function, you can just use the 'Sum' function directly.

    Please follow these steps:

    1.Manually enter the following data.

    2.Put these two fields into the visual as the x-axis(It is normal to display an error because there is no relationship between the two tables)

    3.Use the 'Selectedvalue' function to determine which stage to calculate.

    SELECTEDVALUE function - DAX | Microsoft Learn

    Measure = 
    var _whichstages = SELECTEDVALUE('Table 2'[Total])
    RETURN 
    SWITCH(TRUE(),
    _whichstages = "Current Spend Amt",SUM('Table'[Current Spend]),
    _whichstages = "total Projected",SUM('Table'[Projected])
    _whichstages = "total Budget Amt",SUM('Table'[Budget]) 
    )

    4.Final output

     

    Best Regards,
    Wenbin Zhou
    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

      Dear WenBin,

       

      Just for the nice idea, using the selectedValue, I manage to come close to the result, however, my result X-axis currently display ...Does that means I need to add Qtr into my dummy table - Table 2?

      Q1 Current Spend Amt

      Q1 tota Projected

      Q1 Total Budget Amt

      instead of having the Q1 Grouped.... maybe due to my dataset not in Row format.... Thank you so much again for your kind advise.

       

       

      QuarterRegionCurrent SpendProjectedBudget
      Q1APAC90001000012000
      Q1EUROPE290003100035000
      Q1US260002900027000
      Q1LATIN400040004000
      Q2APAC130001300015000
      Q2EUROPE350003800037000
      Q2US220002500022000
      Q2LATIN400050004000
      Q3APAC130001900014000
      Q3EUROPE330004200036000
      Q3US280003900026000
      Q3LATIN7000130007000
      Q4APAC130003000017000
      Q4EUROPE350005400040000
      Q4US290005700032000
      Q4LATIN7000210007000
      • Anonymous's avatar
        Anonymous
        Not applicable

        Hi Anonymous ,

        If your table data looks like this.I don't think there is any need to add Qtr.

        All you need to do is add the field to the visual and it will filter the data accordingly.

         

        Best Regards,
        Wenbin Zhou