Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
I would like to adjust this measure so that when it identifies the highest accumulated value, it does not replicate that value until the end of the 'dCalendario' table.
File exemple:
https://www.dropbox.com/s/ifm5octlpkq5wng/Forecast_Comunnity.pbix?dl=0
IF(
ISFILTERED('dCalendario'[DataBase]),
ERROR("erro"),
CALCULATE(
[Qty.Liabilities - Forecast],
'dCalendario'[DataBase].[Date],
ALL('dCalendario'[DataBase].[Mês]),
'dCalendario'[DataBase].[Date] <= MAX('dCalendario'[DataBase].[Date])
)
)
For example, when the measure identifies that the highest value is 32, it will only display values up to: 2023 November 32
Year Month FORECAST
2022 | April | 3 |
2022 | May | 4 |
2022 | June | 4 |
2022 | July | 5 |
2022 | August | 5 |
2022 | September | 5 |
2022 | October | 5 |
2022 | November | 5 |
2022 | December | 5 |
2023 | January | 5 |
2023 | February | 6 |
2023 | March | 9 |
2023 | April | 9 |
2023 | May | 16 |
2023 | June | 16 |
2023 | July | 19 |
2023 | August | 26 |
2023 | September | 30 |
2023 | October | 30 |
2023 | November | 32 |
2023 | December | 32 |
2024 | January | 32 |
2024 | February | 32 |
2024 | March | 32 |
2024 | April | 32 |
2024 | May | 32 |
2024 | June | 32 |
2024 | July | 32 |
2024 | August | 32 |
2024 | September | 32 |
2024 | October | 32 |
2024 | November | 32 |
2024 | December | 32 |
@tamerj1 @Jihwan_Kim @Martin_D
Solved! Go to Solution.
This is the code that works as specified:
IF(
ISFILTERED('dCalendario'[DataBase]),
ERROR("erro"),
VAR _DateValue =
// Create a virtual table with a row per date and each cumulated forecast value,
// to then pick the overall maximum forecast value,
// to then pick the minimum date with this maximum forecast value,
// to then return no more values after that date (i.e. any period, e.g. month, that consists only of dates after this date)
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZECOLUMNS (
'tbl_tasks'[Valor]
),
"@MonthlyValue",
VAR _LastDate = CALCULATE ( MAX ( 'dCalendario'[DataBase].[Date] ) )
RETURN
CALCULATE (
[_Qty.baseline - Forecast],
ALLSELECTED('dCalendario'),
'dCalendario'[DataBase].[Date] <= _LastDate
)
),
ALLSELECTED ( 'dCalendario' )
)
// get the maximum forecast value
VAR _MaxValue = MAXX ( _DateValue, [@MonthlyValue] )
// get the first month with the maximum forecast value
VAR _EarliestDateWithMaxValue = MINX ( FILTER ( _DateValue, [@MonthlyValue] = _MaxValue ), [Valor] )
// get the first date of the selected period, e.g. month
VAR _FirstDateInContext = MIN ( 'dCalendario'[DataBase].[Date] )
RETURN
IF (
_FirstDateInContext <= _EarliestDateWithMaxValue,
CALCULATE(
[_Qty.baseline - Forecast],
'dCalendario'[DataBase].[Date], // only include values from dates that exist in the fact table ([Valor] column) and in the date table,
// i.e. no values for before jan 2019 (date table), and no values for before nov 2022 (first month with date on or after jan 2019 with data)
'dCalendario'[DataBase].[Date] <= MAX('dCalendario'[DataBase].[Date]),
ALLSELECTED ( 'dCalendario' )
)
)
)
Thoughts:
BR
Martin
https://www.dropbox.com/s/ifm5octlpkq5wng/Forecast_Comunnity.pbix?dl=0
Are there other way to share the file here ?
This is the code that works as specified:
IF(
ISFILTERED('dCalendario'[DataBase]),
ERROR("erro"),
VAR _DateValue =
// Create a virtual table with a row per date and each cumulated forecast value,
// to then pick the overall maximum forecast value,
// to then pick the minimum date with this maximum forecast value,
// to then return no more values after that date (i.e. any period, e.g. month, that consists only of dates after this date)
CALCULATETABLE (
ADDCOLUMNS (
SUMMARIZECOLUMNS (
'tbl_tasks'[Valor]
),
"@MonthlyValue",
VAR _LastDate = CALCULATE ( MAX ( 'dCalendario'[DataBase].[Date] ) )
RETURN
CALCULATE (
[_Qty.baseline - Forecast],
ALLSELECTED('dCalendario'),
'dCalendario'[DataBase].[Date] <= _LastDate
)
),
ALLSELECTED ( 'dCalendario' )
)
// get the maximum forecast value
VAR _MaxValue = MAXX ( _DateValue, [@MonthlyValue] )
// get the first month with the maximum forecast value
VAR _EarliestDateWithMaxValue = MINX ( FILTER ( _DateValue, [@MonthlyValue] = _MaxValue ), [Valor] )
// get the first date of the selected period, e.g. month
VAR _FirstDateInContext = MIN ( 'dCalendario'[DataBase].[Date] )
RETURN
IF (
_FirstDateInContext <= _EarliestDateWithMaxValue,
CALCULATE(
[_Qty.baseline - Forecast],
'dCalendario'[DataBase].[Date], // only include values from dates that exist in the fact table ([Valor] column) and in the date table,
// i.e. no values for before jan 2019 (date table), and no values for before nov 2022 (first month with date on or after jan 2019 with data)
'dCalendario'[DataBase].[Date] <= MAX('dCalendario'[DataBase].[Date]),
ALLSELECTED ( 'dCalendario' )
)
)
)
Thoughts:
BR
Martin
Thank you, in the given example, it worked perfectly, but in the actual case, there are still some errors,. My objective is to create an S-curve for this table, an S-curve for the planned values based on the "End" column, an S-curve for the projected values based on the "End" column, and a curve for the actual values up to the current day. Could you suggest another approach based on this model that I provided, keeping in mind that this model only has one project? In the original database, I have a column that identifies the projects, and the idea is that when applying a filter on the project name, it would display the curves for each project.
With some shortcomings, you can create an s-curve from your data like this. You can load a Projekt column, then the solution works for multiple projects as well.S-curve
See attached file for solution.
The two major shortcoming are:
BR
Martin
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
9 | |
8 | |
8 |
User | Count |
---|---|
14 | |
12 | |
11 | |
11 | |
8 |