Forum Discussion

lboldrino's avatar
lboldrino
Resolver I
5 years ago
Solved

How can i multiple columns from Different tables With Condition other Cols

TicketCosts

from   to          year     cost

2503502019166,05
3514502019158,51
4515502019150,96
5516502019143,41
6501000002019135,86
2503502020168,54
3514502020160,89
4515502020153,22
5516502020145,56
6501000002020137,9

 

tblTotalticket

Closed MonthYearTotal Tickets
2020.032020288
2020.042020286
2020.052020227
2020.082020201
2020.062020205
2020.012020403
2020.072020260
2020.022020260
2019.042019350
2019.062019234
2019.072019220
2019.082019251
2019.112019429
2019.012019401
2019.052019270
2019.022019241
2019.102019295
2019.122019374
2019.092019203
2019.032019264

 

i need the cost per month where totalTickets beween from /to

2019.01 : if year = 2019 and total tickets between 250 and 350 then Totalcost = 401 *166,05 

tblTotalticket is a summerize Table !!!!! (

Customer_TicketPreis =
SUMMARIZE ( customer_tmp, [Closed Month],customer_tmp[Year], "Total Tickets", SUM(customer_tmp[TicketsAnzahl]))

)

 

ThanX for Your Ideas! 🙂

 

  • Hi lboldrino ,

     

    Please check if this is what you want:

    Column =
    VAR Cost_ =
        CALCULATE (
            SUM ( TicketCosts[cost] ),
            FILTER (
                TicketCosts,
                TicketCosts[year] = tblTotalticket[Year]
                    && TicketCosts[from] <= tblTotalticket[Total Tickets]
                    && TicketCosts[to] >= tblTotalticket[Total Tickets]
            )
        )
    RETURN
        [Total Tickets] * Cost_
    

     

     

    Best Regards,

    Icey

     

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

3 Replies

  • Icey's avatar
    Icey
    Community Support

    Hi lboldrino ,

     

    Please check if this is what you want:

    Column =
    VAR Cost_ =
        CALCULATE (
            SUM ( TicketCosts[cost] ),
            FILTER (
                TicketCosts,
                TicketCosts[year] = tblTotalticket[Year]
                    && TicketCosts[from] <= tblTotalticket[Total Tickets]
                    && TicketCosts[to] >= tblTotalticket[Total Tickets]
            )
        )
    RETURN
        [Total Tickets] * Cost_
    

     

     

    Best Regards,

    Icey

     

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

  • Hi lboldrino ,

     

    You will need to have a relatioship between these 2 tables on a common column.

    Have you got any relationship?

     

    Thanks,

    Pragati

    • lboldrino's avatar
      lboldrino
      Resolver I

      i create a Floag col in Ticketcosts:

       

      2503502019166,05 €1
      3514502019158,51 €2
      4515502019150,96 €3
      5516502019143,41 €4
      6501000002019135,86 €5
      2503502020168,54 €6
      3514502020160,89 €7
      4515502020153,22 €8
      5516502020145,56 €9
      6501000002020137,90 €10

       

      and in customer_totaltickets: Flag =
      switch(
      true(),
      customer_TicketPreis[Total Tickets] >249 && customer_TicketPreis[Total Tickets] < 351 && customer_TicketPreis[Year]= 2019,1
      ,customer_TicketPreis[Total Tickets] >350 && customer_TicketPreis[Total Tickets] < 451 && customer_TicketPreis[Year]= 2019,2
      ,customer_TicketPreis[Total Tickets] >450 && customer_TicketPreis[Total Tickets] < 551 && customer_TicketPreis[Year]= 2019,3
      ,customer_TicketPreis[Total Tickets] >550 && customer_TicketPreis[Total Tickets] < 651 && customer_TicketPreis[Year]= 2019,4
      ,customer_TicketPreis[Total Tickets] >650 && customer_TicketPreis[Total Tickets] < 100000 && customer_TicketPreis[Year]= 2019,5
      ,customer_TicketPreis[Total Tickets] >350 && customer_TicketPreis[Total Tickets] < 451 && customer_TicketPreis[Year]= 2020,7
      ,customer_TicketPreis[Total Tickets] >450 && customer_TicketPreis[Total Tickets] < 551 && customer_TicketPreis[Year]= 2020,8
      ,customer_TicketPreis[Total Tickets] >550 && customer_TicketPreis[Total Tickets] < 651 && customer_TicketPreis[Year]= 2020,9
      ,customer_TicketPreis[Total Tickets] >650 && customer_TicketPreis[Total Tickets] < 100000 && customer_TicketPreis[Year]= 2020,10
      ,customer_TicketPreis[Total Tickets] >249 && customer_TicketPreis[Total Tickets] < 351 && customer_TicketPreis[Year]= 2020,6
      ,99)

       

      Closed MonthYearTotal TicketsFlag

      2020.0320202886
      2020.0420202866
      2020.05202022799
      2020.08202020199
      2020.06202020599
      2020.0120204037
      2020.0720202606
      2020.0220202606
      2019.0420193501
      2019.06201923499
      2019.07201922099
      2019.0820192511
      2019.1120194292
      2019.0120194012
      2019.0520192701
      2019.02201924199
      2019.1020192951
      2019.1220193742
      2019.09201920399
      2019.0320192641

       

      This works, do you have a better idea for

      customer_totaltickets: Flag =
      switch(
      true(),
      customer_TicketPreis[Total Tickets] >249 && customer_TicketPreis[Total Tickets] < 351 && customer_TicketPreis[Year]= 2019,1
      ,customer_TicketPreis[Total Tickets] >350 && customer_TicketPreis[Total Tickets] < 451 && customer_TicketPreis[Year]= 2019,2
      ,customer_TicketPreis[Total Tickets] >450 && customer_TicketPreis[Total Tickets] < 551 && customer_TicketPreis[Year]= 2019,3
      ,customer_TicketPreis[Total Tickets] >550 && customer_TicketPreis[Total Tickets] < 651 && customer_TicketPreis[Year]= 2019,4
      ,customer_TicketPreis[Total Tickets] >650 && customer_TicketPreis[Total Tickets] < 100000 && customer_TicketPreis[Year]= 2019,5
      ,customer_TicketPreis[Total Tickets] >350 && customer_TicketPreis[Total Tickets] < 451 && customer_TicketPreis[Year]= 2020,7
      ,customer_TicketPreis[Total Tickets] >450 && customer_TicketPreis[Total Tickets] < 551 && customer_TicketPreis[Year]= 2020,8
      ,customer_TicketPreis[Total Tickets] >550 && customer_TicketPreis[Total Tickets] < 651 && customer_TicketPreis[Year]= 2020,9
      ,customer_TicketPreis[Total Tickets] >650 && customer_TicketPreis[Total Tickets] < 100000 && customer_TicketPreis[Year]= 2020,10
      ,customer_TicketPreis[Total Tickets] >249 && customer_TicketPreis[Total Tickets] < 351 && customer_TicketPreis[Year]= 2020,6
      ,99)