Forum Discussion

Syndicate_Admin's avatar
Syndicate_Admin
Icon for Administrator rankAdministrator
2 years ago
Solved

Create a graph with calculated values between 2 tables per week

Hello everyone

I want to generate a graph using values from two tables per week

Table 1 Table 2
Component 1WeekValue Component 2WeekValue
A112.00 A218.00
A113.00 A215.00
A115.00 B214.00
B112.00 B214.00
B114.00 B213.00
A122.00 C214.00
A125.00 C212.00
B126.00 B226.00
C124.00 B225.00
C125.00 B224.00
A147.00 C221.00
B143.00 C222.00
B148.00 A138.00
B141.00 B237.00
B144.00 C234.00
C145.00 C233.00
C142.00 A245.00
C141.00 A246.00
B244.00
B244.00
C243.00
C241.00

For the graph, the values are given by subtracting the weekly average of each component subtracted from a constant.

ProductComponent 1Component 2Fromula to Chart
AA1A2A=(10)-(A1 - A2)
BB1B2B=(11)-(B1 - B2)
CC1C2C=(15)-(C1 - C2)

The problem is that there are weeks when you don't have a component, in that case you don't graph the value of that week

WeekAverage A1Average B1Average C1 Average A2Average B2Average C2
13.333.67N/A 6.503.673.00
23.506.004.50 N/A5.001.50
3N/AN/AN/A 8.007.003.50
47.004.002.67 5.504.002.00
Calculation
WeekProduct AProduct BProduct C
113.1711.00
2 10.0012.00
3
48.5011.0014.33

The graph would look something like this:

I hope you can help me

Best regards

  • Hello

    Thank you very much for the answer, I had to adjust the graph a little so that it was identical to what I need, there was something that did not fit me but it was a mistake of mine in the table, but the answer is correct

    Thank you and greetings!

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi,Syndicate_Admin 

    Regarding the issue you raised, my solution is as follows:

    1.First I have created the following table and the column names and data are the data you have given:

    2.Create calculated table references:

    Table = UNION('Table1','Table2')

    3.Create calculated column references:

    Average A1 = CALCULATE(AVERAGE('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Week]),'Table'[Component 1]="A1"))
    Average A2 = CALCULATE(AVERAGE('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Week]),'Table'[Component 1]="A2"))
    Average B1 = CALCULATE(AVERAGE('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Week]),'Table'[Component 1]="B1"))
    Average B2 = CALCULATE(AVERAGE('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Week]),'Table'[Component 1]="B2"))
    Average C1 = CALCULATE(AVERAGE('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Week]),'Table'[Component 1]="C1"))
    Average C2 = CALCULATE(AVERAGE('Table'[Value]),FILTER(ALLEXCEPT('Table','Table'[Week]),'Table'[Component 1]="C2"))
    Product A = IF('Table'[Average A1]&&'Table'[Average A2],
    10-'Table'[Average A1]+'Table'[Average A2],BLANK())
    
    Product B = IF('Table'[Average B1]&&'Table'[Average B2],
    11-'Table'[Average B1]+'Table'[Average B2],BLANK())
    
    
    Product C = IF('Table'[Average C1]&&'Table'[Average C2],
    15-'Table'[Average C1]+'Table'[Average C2],BLANK())
    

    4.Here's my final result, which I hope meets your requirements.

    Please find the attached pbix relevant to the case.

     

    Best Regards,

    Leroy Lu

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

     

     

     

    • Billy_82476344's avatar
      Billy_82476344
      Frequent Visitor

      Hello

      Thank you very much for the answer, I had to adjust the graph a little so that it was identical to what I need, there was something that did not fit me but it was a mistake of mine in the table, but the answer is correct

      Thank you and greetings!