Forum Discussion

petroswheels's avatar
petroswheels
New Member
6 years ago

Joining data for measures

Hi All - I'm a beginning user, so please forgive this rookie question. 

 

I have two sets of data, that I'd like to connect to get a percentage of the regional goal that was met for a given period. I'm having trouble visualizing in my head how to roll up the raw data (count orders), and connect with the projected goal. The structuring of the two tables are vastly different. In order to try to describe it better, I represented the data on the attached screenshot. 

 

I appreciate any help! Thanks. 

 

1 Reply

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    petroswheels - First thing I would do is unpivot your "state" columns in Table 2. I would then create a bridge table between your two tables using this:

     

    State Table = DISTINCT('Table1'[State])

     

    Create the relationships between the tables and you might need them to be bi-directional. Then create a measure like the following:

    Measure =
      VAR __State = MAX('States Table'[State])
      VAR __Month = MAX('Table 2'[Date])
      VAR __Count =
        COUNTROWS(
          FILTER(ALL('Table 1'),[State] = __State && MONTH([Date of Order]) = MONTH(__Month) && YEAR([Date of Order]) = YEAR(__Month)
          )
         )
       VAR __Goal = MAX('Table 2'[Value])
    RETURN
      [__Count] / __Goal
          
      

    Something along those lines.