Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
BTW30s
New Member

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.
Capture.PNG

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

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. 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

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.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

2 REPLIES 2
Greg_Deckler
Super User
Super User

Check out my Open Tickets Quick Measure. Just learned how to elegantly solve these types of problems thanks to @Phil_Seamark's excellent new book, Beginning DAX with Power BI: The SQL Pro’s Guide to Better Business Intelligence. Fantastic resource. Here is the link to the Quick Measure:

https://community.powerbi.com/t5/Quick-Measures-Gallery/Open-Tickets/m-p/409364#M147

 

 


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...
Greg_Deckler
Super User
Super User

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.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.