Forum Discussion

NManku's avatar
NManku
Regular Visitor
8 years ago
Solved

Comparing monthly aggregated data from one table to monthly targets in another table

Hi there,

 

I'm relatively new to Power BI but learning!

 

I have two sets of data which I want to link together, but I'm struggling to get to exactly what I want.

In one table I have donation amount and dates, and in another I have the monthly target for total donations.

I want to show in one chart how we're doing actual vs. target (see examples below).

 

Any help would be massively appreciated.

 

Cheers,

Nic

 

Table 1

Donation AmountDonation Date
515/04/17
1023/04/17
2001/05/17
1018/05/17
502/06/17
7

30/06/17

 

Table 2

MonthTarget
Apr-1720
May-1730
Jun-1712

 

 

Desired outcome

MonthActual Donation TotalTarget Donation TotalDifference
Apr-171520-5
May-1730300
Jun-171215-3
  • Hi NManku, this is a typical many-to-1 scenario.  You would begin (in Data View) by adding a calculated column to Table 1 that transforms the donation date-month-year into month-year, which is the same format and data type as Table 2's "month" column.

     

    For example, if Table 2's "month" column is a "text" type, then the calculated column should be text as well.  However, if it's a date type that uses 1-Apr-2017 to represent the whole month, then the calculated column should map DD-Apr-2017 to 1-Apr-2017.

     

    Next, in the Relationship View, link this calculated column to the "month" column in Table 2.

     

    Then, you'd add three measures :

    Actual Donation Total := SUM( 'Table 1'[Donation Amount] )

    Target Domation Total := AVERAGE('Table 2'[Target] )

    Difference := [Actual Donation Total] - [Target Donation Total]

     

    Finally, go to Report View, add a Table visual,  and put "Month" from Table 2 on the rows, and the three measures on the Values.

     

     

2 Replies

  • Hi NManku, this is a typical many-to-1 scenario.  You would begin (in Data View) by adding a calculated column to Table 1 that transforms the donation date-month-year into month-year, which is the same format and data type as Table 2's "month" column.

     

    For example, if Table 2's "month" column is a "text" type, then the calculated column should be text as well.  However, if it's a date type that uses 1-Apr-2017 to represent the whole month, then the calculated column should map DD-Apr-2017 to 1-Apr-2017.

     

    Next, in the Relationship View, link this calculated column to the "month" column in Table 2.

     

    Then, you'd add three measures :

    Actual Donation Total := SUM( 'Table 1'[Donation Amount] )

    Target Domation Total := AVERAGE('Table 2'[Target] )

    Difference := [Actual Donation Total] - [Target Donation Total]

     

    Finally, go to Report View, add a Table visual,  and put "Month" from Table 2 on the rows, and the three measures on the Values.

     

     

    • Aimeeclaird's avatar
      Aimeeclaird
      Icon for Helper IV rankHelper IV

      Hi DAX0110 

       

      This thread has been really helpful to me as i'm trying to solve a similar requirement. 

       

      There is a slight difference in my data in that I have a variety of different contracts, each sale was completed under a contract and i'd like to lookup the target value for that contract. For example;

       

      Target table = 

      ContractTarget ValueTarget Period
      11000000Jan 2020
      21500000Feb 2020
      32000000March 2020
      1500000Jan 2020
      21000000Feb 2020
      31750000March 2020
      12500000Jan 2020
      22000000Feb 2020
      31750000March 2020

       

      Sales Data = 

      ContractSale ValueDate of Sale
      150000001/01/2020
      245000017/01/2020
      334000022/03/2020
      12500004/02/2020
      23450005/03/2020
      333300012/03/2020
      112567030/03/2020
      240000030/01/2020
      335000015/03/2020

       

      Please can you advise how I can adapt the solution you've provided below to also consider which contract we need to lookup?

       

      Many thanks in advance!