Forum Discussion

JT317's avatar
JT317
New Member
3 years ago
Solved

filterable timespan

Der All,

 I've got some projects with costs over a timespan (start and end date are given). We assume these costs split linear per month (cost per month= total costs / count of month between start and end):

 

projectstartendcostcost per month
A01.07.202131.05.2024140000041176.47
B15.06.202220.06.20239000000750000
C01.05.202330.04.20450000045454.55

 

I have already managed to create a measure which calculates the sum of cost per month. Now I need to create another measure which gives me the sum of the costs for an filterable timespan that can start before the start date, end after and can contain as many months as the user wants to. So i want to calculate the sum over the projects: cost per month * count of month in selected timespan that lay between start and end date

  • Anonymous's avatar
    Anonymous
    3 years ago

    Hi JT317 

    You can refer to the following example.

    The sample data is the same as yours.

    First you need to create a date table

    e.g 

    Then create a measure

    Measure = var a=ADDCOLUMNS(ALLSELECTED('Table 2'),"Eomonth",EOMONTH([Date],0))
    var b=SUMMARIZE(FILTER(a,[Date]>=SELECTEDVALUE('Table'[start])&&[Date]<=SELECTEDVALUE('Table'[end])),[Eomonth])
    return COUNTROWS(b)*SUM('Table'[cost per month])
    

    Output

    Best Regards!

    Yolo Zhu

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

1 Reply

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi JT317 

    You can refer to the following example.

    The sample data is the same as yours.

    First you need to create a date table

    e.g 

    Then create a measure

    Measure = var a=ADDCOLUMNS(ALLSELECTED('Table 2'),"Eomonth",EOMONTH([Date],0))
    var b=SUMMARIZE(FILTER(a,[Date]>=SELECTEDVALUE('Table'[start])&&[Date]<=SELECTEDVALUE('Table'[end])),[Eomonth])
    return COUNTROWS(b)*SUM('Table'[cost per month])
    

    Output

    Best Regards!

    Yolo Zhu

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