Forum Discussion

nardtmo's avatar
nardtmo
Helper III
5 years ago
Solved

date comparison

Hi All,

 

Trying to create the report, when i search for  student id it will compare a prior week period total cost from Project start &  a week after project finish.

example 

if i select Student 1  will compare ( project start 12/20/20 - WK 51)

will sum cost from 12/13/20 to 12-19/20 - WK50

 

and (project finish 1/2/2021 - WK1)

will sum cost from 1/3/21 to 1/9/21 -WK2

 

thanks in advance

 

 

Table 1

StudentProject startProject Finish
Student 112/20/20201/2/2021
Student 21/4/20201/11/2021

 

Table 2

Datedayweek studentCost
12/13/2020Sun51Student 11,024
12/14/2020Mon51Student 11,257
12/15/2020Tue51Student 11,357
12/16/2020Wed51Student 11,328
12/17/2020Thu51Student 11,280
12/18/2020Fri51Student 11,380
12/19/2020Sat51Student 11,133
12/20/2020Sun52Student 11,036
12/21/2020Mon52Student 11,481
12/22/2020Tue52Student 11,402
12/23/2020Wed52Student 11,540
12/24/2020Thu52Student 11,350
12/25/2020Fri52Student 11,068
12/26/2020Sat52Student 1958
12/27/2020Sun53Student 11,007
12/28/2020Mon53Student 11,378
12/29/2020Tue53Student 11,298
12/30/2020Wed53Student 11,533
12/31/2020Thu53Student 11,338
01/01/2021Fri1Student 11,239
01/02/2021Sat1Student 11,087
01/03/2021Sun2Student 11,080
01/04/2021Mon2Student 11,369
01/05/2021Tue2Student 11,531
01/06/2021Wed2Student 11,324
01/07/2021Thu2Student 11,313
01/08/2021Fri2Student 11,450
01/09/2021Sat2Student 1888
  • Thanks so much for the help. This also will give the solution. But got to many data to use calculated column. 

7 Replies

    • nardtmo's avatar
      nardtmo
      Helper III

      Ashish,

      Noticed with this formula it will start calculating cost day after the finish date + seven days. 

       

      Next week cost = CALCULATE([Total cost],DATESBETWEEN('Calendar'[Date],[Finish date]+1,[Finish date]+7))
       
      is there a way to to calculate the a week after finish date. say for example below
       
      finish date falls under week 2. cost calculation should start from Week 3.
      Also i i only want to calculate working days in that week what will be the formula.
       
      date wk
      1/3/2021 2 finish date
      1/4/2021 2
      1/5/2021 2
      1/6/2021 2
      1/7/2021 2
      1/8/2021 2
      1/9/2021 2
      1/10/2021 3 start calculation from here
      1/11/2021 3
      1/12/2021 3
      1/13/2021 3
      1/14/2021 3
      1/15/2021 3
      1/16/2021 3 end here as next week cost
       
      apologize kinda new in pbi. Appreciate the help.
       
       
       
      • Ashish_Mathur's avatar
        Ashish_Mathur
        Super User

        Hi,

        In the Calendar table, you will have to give me 2 additional columns - Week number and Isworkday (with a Yes/No)?

  • smpa01's avatar
    smpa01
    Community Champion

    nardtmopbix attached

    https://drive.google.com/file/d/1OLeszOikKkGTl9SeCYNB8HCDq0HgkqGX/view?usp=sharing

     

    create a calculated columns in table 1

    [table 1 (renamed as master), table 2 (renamed as data)]

     

     

     

     

    startuqid = IF(LOOKUPVALUE(data[week],data[student],master[Student],data[Date],master[Project start])=0,0, LOOKUPVALUE(data[week],data[student],master[Student],data[Date],master[Project start])-1)
    finishuqid = IF(LOOKUPVALUE(data[week],data[student],master[Student],data[Date],master[Project Finish])=0,0,LOOKUPVALUE(data[week],data[student],master[Student],data[Date],master[Project Finish])+1)

     

     

     

     

     then the following measures

     

     

     

     

    finishtotal:= SUMX(FILTER(data,data[week]=MAX(master[finishuqid])),[Cost])
    
    starttotal:= SUMX(FILTER(data,data[week]=MAX(master[startuqid])),[Cost])

     

     

     

     

     no relationship required

    • nardtmo's avatar
      nardtmo
      Helper III

      Thanks so much for the help. This also will give the solution. But got to many data to use calculated column.