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.
Hi all, I have a nice brainteaser for you, I'm getting crazy with 😫
I have the following table with information regarding closed, running or ongoing contracts, where I always have a startDate and an EndDate and an already calculated column with "EarningsPerDay".
Contract ID | StartDate | EndDate | EarningsPerDay | ... |
2 | 10.10.2020 | 31.12.2022 | 5,00 | |
3 | 01.02.2021 | 15.03.2021 | 7,50 | |
4 | 12.03.2021 | 18.05.2021 | 2,30 | |
... |
Now I would like to see the earnings within a specific timeframe over the contracts, which are active within this timeframe (for example in a barchart assigned to days, months, aso.) and it should be possible to get an overview of all currently active contracts within a timeframe, for example:
Chosen Timeframe => Active Contract IDs
I've already created a Calendar-Table, but I don't know, how to deal with the timeframe between the StartDate and the EndDate.
I think I need some kind of multidimensional table with the following dimensions
At the moment I only have the cumulated EarningsWithinTimeframe, using the following Formula, which seems to work correctly,
but I didn't get the correct values shown in a barchart with years and months. The barchart shows only the same value in each bar.
EarningsWithinTimeframe = CALCULATE(
SUMX(
VALUES(_Calendar[Date]),
SUMX(Contract,
IF(
Contract[StartDate] <= _Calendar[Date] &&
Contract[EndDate] >= _Calendar[Date]
Contract[EarningsPerDay],0
)
)
),
ALLSELECTED(_Calendar)
)
Solved! Go to Solution.
Hello,
thank you @Jihwan_Kim, with your help I found the following solution, it's a bit a mixture between your solution and mine.
With the following measure, you get the sum of all earnings within the selected timeframe:
Earnings total measure = CALCULATE(
SUMX(
VALUES(Dates[Date]),
SUMX(Earnings,
IF(
Earnings[StartDate] <= Dates[Date] &&
Earnings[EndDate] >= Dates[Date],
Earnings[EarningsPerDay],0
)
)
)
)
And if you would like to get a list with all active contracts in this timeframe, you can use the following measure as filter on a table.
You get all contracts, which match the following cases:
Active Contracts = COUNTROWS(
FILTER(Earnings,
Earnings[StartDate] <= MAX(Dates[Date]) &&
Earnings[EndDate] >= MIN(Dates[Date])
)
)
Apply this measure as a filter to a table and choose to show all elements, which are not blank.
I hope, this is helpful for other people in the community,
thanks a lot,
Stefan
Thank You @Jihwan_Kim this goes in the right direction. The "earnings total measure" are too high in edgecases (earnings starts/ends somewhere within the selected timeframe) because it count's also the days, before earnings start oder after earnings ended. I've made a mixture of your "earnings total measure".
Now the barchart looks good. I still have some issues, which I don't understand. I'll check them in the next days and hopefully come back with a solution or further questions 🙂
Thanks a lot!!!
Hi, @serialize
Please check the below picture and the sample pbix file's link down below.
Hi, My name is Jihwan Kim.
If this post helps, then please consider accept it as the solution to help other members find it faster, and give a big thumbs up.
Linkedin: linkedin.com/in/jihwankim1975/
Twitter: twitter.com/Jihwan_JHKIM
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Hello,
thank you @Jihwan_Kim, with your help I found the following solution, it's a bit a mixture between your solution and mine.
With the following measure, you get the sum of all earnings within the selected timeframe:
Earnings total measure = CALCULATE(
SUMX(
VALUES(Dates[Date]),
SUMX(Earnings,
IF(
Earnings[StartDate] <= Dates[Date] &&
Earnings[EndDate] >= Dates[Date],
Earnings[EarningsPerDay],0
)
)
)
)
And if you would like to get a list with all active contracts in this timeframe, you can use the following measure as filter on a table.
You get all contracts, which match the following cases:
Active Contracts = COUNTROWS(
FILTER(Earnings,
Earnings[StartDate] <= MAX(Dates[Date]) &&
Earnings[EndDate] >= MIN(Dates[Date])
)
)
Apply this measure as a filter to a table and choose to show all elements, which are not blank.
I hope, this is helpful for other people in the community,
thanks a lot,
Stefan
Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City
Check out the April 2024 Power BI update to learn about new features.
User | Count |
---|---|
49 | |
26 | |
20 | |
15 | |
12 |
User | Count |
---|---|
57 | |
49 | |
44 | |
19 | |
18 |