Forum Discussion

PatrickWong's avatar
PatrickWong
Icon for Helper I rankHelper I
7 years ago
Solved

Multiply Daily Value by Monthly Value and type

I have 2 tables, 1 has monthly data and type and the other has the daily data

 

I want to multiply my daily value by my monthly value of the correct type in a measure so that I can later splice the sum of the cost by type per month

 

Sample Data:

Monthly data  
Datetyperate
1 January, 2019red10
1 January, 2019blue20
1 February, 2019red11
1 February, 2019blue21
1 March, 2019red12
1 March, 2019blue23

 

 

Daily Data   (Desired output)
DateAmount Cost
1 January, 201910red100
2 January, 201911blue220
3 January, 201912blue240
4 January, 201911red110
2 January, 201910red110
2 February, 201911blue231
2 February, 201911red121
2 April, 201910blue210
3 January, 201910blue230
3 January, 201910red120
3 April, 201911red132
3 April, 201912blue276

 

  • PatrickWong add following calculated column and that will do it, change column and table name as per your date model.

     

    Rate = Monthly Data Table

    Rate Date = Daily Data Table

     

    Cost = 
    LOOKUPVALUE( Rate[rate], Rate[Date],EOMONTH('Rate Date'[Date],-1)+1,Rate[type], 'Rate Date'[Type]) *
    'Rate Date'[Amount]

1 Reply

  • PatrickWong add following calculated column and that will do it, change column and table name as per your date model.

     

    Rate = Monthly Data Table

    Rate Date = Daily Data Table

     

    Cost = 
    LOOKUPVALUE( Rate[rate], Rate[Date],EOMONTH('Rate Date'[Date],-1)+1,Rate[type], 'Rate Date'[Type]) *
    'Rate Date'[Amount]