Forum Discussion

BTW30s's avatar
BTW30s
New Member
8 years ago
Solved

Trend line, calculation for each row

Hi,

I have a very complex problem. I'm new to dax but I'm not sure it can solve this.

I have a table of id, start date and end date.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

Now I need to create snapshot table. I created new date table using function calendarauto. But now I need to calculate column or a measure like so:

If date row from date table is between open and closed date, it will count as 1, otherwise 0.

For example:  id 1, should be calculated for january, february, march and april, for id 2 only in january, and so on...

In chart (or table) values should be:

January: 2,

February: 5,

March: 9,

April: 7

 

I hope I explained it well. Thanks for any help. 

  • Because you didn't provide data in a format that I can copy and paste and I don't feel like retyping all of your data, I probably shouldn't attempt to answer this without testing. Please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

     

    But, here goes. In your Calendar table, create a new column like this:

     

    Column = COUNTROWS(FILTER(ALL(Incidents),Incidents[Open Date]<=[Date]&& Incidents[Close Date]>=[Date])) 

    I'm fairly sure that is correct. It feels correct.

2 Replies