Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
6 years ago

Calculate a value with multiple tables

I have this table; it shows for a city the monthly percentage that the order value will increase

City Month Percentage

new yorkjan0,03
new yorkfeb0,02
new yorkmar0,02
new yorkapr0,01
new yorkmay0,03
new yorkjun0,03
new yorkjul0,03
new yorkaug0,03
new yorksep0,03
new yorkoct0,03
new yorknov0,02
new yorkdec0,02

 

In this table I have for a customer (which lifes in a city) the amount of order value. As you can see there is also the date in it

cno date ordval

1007saturday 2 january 201621
1018saturday 9 january 2016107
1018saturday 9 january 201631
1003thursday 21 januari 2016321
1016tuesday 2 february 2016104
1016wednesday 3 february 201625
1006monday 8 february 201686

 

I want to know the amount the 'ordval' will increase with the above percentages (first table). I don't know how to do this, to link the month with the date from customer. I do want a new column with these values.

 

I have this table for the customers, where you can see where the customers lifes. 

cno name  cityabbrev

1003GeorgeNY
1006BillNY
1016SteveNY
1018JohnNY

 

Which is linked to a city table:

city cityabbrev

new yorkNY

2 Replies

  • V-lianl-msft's avatar
    V-lianl-msft
    Community Support

    Hi Anonymous ,

     

    The major issue is to establish a relationship between tables.

    If the date in the “city month percentage” table is not date type, you need to create a calendar column.

    You can try this DAX:

    1. Get month of Whole number type

    NO_month = SWITCH('City Month Percentage'[month], "jan",1,"feb",2,"mar",3,"apr",4,"may",5,"jun",6,"jul",7,"aug",8,"sep",9,"oct",10,"nov",11,"dec",12,0) 

    2. create a calendar column

    DATE_month = DATE(2016,'City Month Percentage'[NO_month],1) 

    3. Format month

    T_month = FORMAT('City Month Percentage'[DATE_month],"MMMM") 
    month = FORMAT('cno date ordval'[date],"MMMM" ) 

    4. Establish relationships between tables

    This is the result:

    You also can refer to the .pbix

     

    Best Regards,

    Liang

    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

      V-lianl-msft 

       

      Thanks for the reply! I found another solution to get the whole month name in the percentage table and I have the month in the ordval table. So I want to make the relation but I only can make a many to many relation between these tables. 
      I also wonder how you get the percentages in the ordval table. 

       

      Example (ordval table):

      cno date ordval monthname year

      1007saturday 2 january 201621January2016
      1007friday 26 february 2016260February2016
      1007wednesday 2 march 2016241March

      2016

      (keep in mind that I have for every month order values but it is too much to show)

       

      Example (percentages table):

      city month percentage month_full

      new yorkjan0,03January
      new yorkfeb0,02February
      new yorkmar0,02March
      new yorkapr0,01April
      chicagojan0,04January
      chicagofeb0,04February
      chicagomar0,03March

      As you can see I have more city's, with duplicate months. Maybe that is occuring the problem? (this goes also further, every city has 12 months)