Hi @JoaoMonteiro. Sounds like DAX can do this easily … can you attach a dataset and your work-in-progress PBIX file? Also, I’m guessing you want the period restricted to whatever year you have selected in your slicer (your example is for 2018 … should all periods use the same filters for 2018?).
Greg
What I Sample.pbix (440.4 KB) which is the following:
When I select the year 2018 I intend to perform the calculation on all rows of all elements whose EntryDate is less than 01/01/2018 and ExitDate is greater than 01/01/2018 or whose EntryDate is greater than 01/01/2018 but the EntryDate is less than 12/31/2018.
Sorry … I’m missing something … your original question asked about StartOfPeriod and EndOfPeriod and had a table with Id and Iup … is this a different dataset/PBIX?
Greg
Please note that this is not an on-demand forum, so it might take some time for members who give up their free time to provide support, to have a chance to review and respond to your question.
I’ve just taken a look and give this a go.
Count Days =
VAR YearSelected = VALUES( DiscDate[Year] )
VAR DatesInYear = CALCULATETABLE( VALUES('Date'[Date]), 'Date'[Year] IN YearSelected )
VAR StartDate = SELECTEDVALUE( RpgResources[EntryDate] )
VAR EndDate = SELECTEDVALUE( RpgResources[ExitDate] )
VAR ListDates = CALCULATETABLE( VALUES('Date'[Date]), 'Date'[Date] >= StartDate && 'Date'[Date] <= EndDate )
RETURN
COUNTROWS(
INTERSECT( DatesInYear, ListDates )
)
.
Here’s your sample file. Sample (5).pbix (417.7 KB)
I hope this is helpful
I’m really sorry and I ask you to accept my apologies if I was too insistent.
I really appreciate your work and your support.
Believe me that one day I would like to be in your role to be able to collaborate and help this whole community.
My sincere thanks.
I understood the idea Melissa shared but I couldn’t apply it correctly.
Would it be possible to help me?
I have been stuck on this problem for more than a week.
Thank you very much for your understandingSample (5).pbix (471.3 KB)
Your solution was not exactly what I needed but it was the push to get there.
You can’t imagine how grateful I am.
Now a piece of advice, please.
I’ve been working on Power BI and DAX for just over 6 months.
Despite many hours of study, I am still at a very early stage.
I have taken many of the DNA Enterprise courses.
How can I, in your opinion, evolve more quickly?
I would like to be really good, almost like you.
To add to Melissa’s response, I would say the following:
Watching the Enterprise DNA videos will provide you a great foundation but alone will only take you so far. Watching videos is an inherently passive experience, and needs to be reinforced by lots and lots of repetition.
Your Enterprise DNA membership provides you three awesome ways to get those reps:
Participate in the Data Challenges – and to maximize your learning, once you take a look at the specific challenge, set a number of practical learning goals for your entry. For example, I’m going to: 1) utilize conditional page navigation; 2) implement a decomposition tree analysis; 3) use calculation groups for my time intelligence measures.
Be sure to stretch yourself into new areas, even at the risk of failing on some of your stretch goals. An amazing example of this was @Alex7891’s entry in Data Challenge #11
Participate in the Problem of the Week – and not only work to provide your solution on the problem, but also review the other solutions that come in and learn from their approaches, since often there are many different ways to tackle the same problem in PowerBI.
Start Providing Solutions on the Forum – look for questions that you can answer, and also ones you have to stretch your knowledge to try to resolve. You may not actually get to a solution on these latter ones, but you will learn a ton in the process and when the solution is posted it will be a lot more meaningful to you.
To borrow a quote from Alberto Ferrari, all three of these things are simple but not easy. However, I 100% guarantee if you put in the time and effort to do these three things you will progress quickly in your Power BI skills.