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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
acbg
Resolver III
Resolver III

Measure that calculates each row based on slicer

Two tables: Date Table and Fact Table

Date table is connected to the Fact Table based on Project Start Date. 

 

The Fact Table also has Project End Date as well.

 

Have a slicer that is based on Project Start Date.

 

To get the Number of Project Days, I can calculate the difference between Project Start and End Date but since we have slicer based on start date I will have to factor that in as well.



Example:
Slicer has date range 1/1/2017 and 3/1/2017.
3 Project that start dates fall between these dates.
Project A start date is 2/1/2017 and end date is 2/5/2017. Project B Start Date is 1/1/2017 and  ends of 3/20/2017.
Project C starts on 12/1/2016 and ends on 1/30/2017.
So the sum of days that fall between the slicer date range is 92: 
Project A = 4  (2/4 - 2/1)
Project B = 59 (3/1 - 1/1)
Project C = 29  (1/30 - 1/1)

 

If there a way to get the 92 dynamically through a measure?

 

4 REPLIES 4
parry2k
Super User
Super User

@acbg what is the structure of your fact table? Do you have start and end date on same row, and if projected is not completed I guess in that case end date is blank, correct?

 

if that is the case, you can add another field called "projectdays" and use that to get total number of days it took to complete the project. 



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k  Project End date is in different column.

I am trying to get the total project days that falls between the slicer dates. 

 

If the project days is 365 but the slicer selection is only for 2 months and the project falls between the slicer range then the measure should show 60 days. If the project has only one month that overlaps with the slicer then the project days would be 30days for that project.

@acbg can you share sample data and how your table is structured?

 

Is it something like

 

ProjectId        Start Date         End Date

1                    Jan 1 2019         Jan 30 2019

2                    Feb 2 2019        

3                    Jan 1 2018        Jan 30 2019

 

So in above sample , project 2nd is not completed and other two are completed



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

@parry2k  Yes that is how the table structured.

I have a way to do this in Power Query but would like something more dynamic through the measure.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

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.