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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Pedro_borges
Regular Visitor

How to create a dynamic return measure

Hi,

 

I need to create a dynamic return graph in power BI to calculate return for a given period (Final/First Value), based in one slicer for Fund, and other for date, like below:

Pedro_borges_0-1692021302035.png


I tried to create a measure like the one below, but it gives always 1.

Return Measure = DIVIDE(
    SELECTEDVALUE(Resultados[Cota FIC]),CALCULATE(SELECTEDVALUE(Resultados[Cota FIC]), FIRSTDATE(Resultados[Data]))
)
How can I achieve this?
1 ACCEPTED SOLUTION
Alef_Ricardo_
Resolver II
Resolver II

It seems that you are trying to create a measure in Power BI to calculate the return for a given period based on two slicers, one for Fund and one for date. However, the measure you have created always returns 1.

 

One possible reason for this issue could be that the SELECTEDVALUE function is not returning the expected value. The SELECTEDVALUE function returns the selected value when a single value is selected in the specified column, otherwise it returns the alternate result or blank if no alternate result is provided. You can try using the MAX or MIN function instead of SELECTEDVALUE to see if it resolves the issue.

 

Another possible reason could be that the FIRSTDATE function is not returning the expected value. The FIRSTDATE function returns the first date in the current context for the specified column of dates. Make sure that the column you are passing to the FIRSTDATE function contains dates and that the current context is set correctly.

If these suggestions do not resolve your issue, it would be helpful to have more information about your data model and the context in which you are using this measure. You may also want to consider posting your question on a Power BI forum or community where experts can provide more specific guidance.

 

Retorno =
VAR ValorInicial =
CALCULATE(
MIN(Resultados[Cota FIC]),
FILTER(
ALLSELECTED(Resultados),
Resultados[Data] = MIN(Resultados[Data])
)
)
VAR ValorFinal =
CALCULATE(
MAX(Resultados[Cota FIC]),
FILTER(
ALLSELECTED(Resultados),
Resultados[Data] = MAX(Resultados[Data])
)
)
RETURN
DIVIDE(ValorFinal, ValorInicial)

View solution in original post

1 REPLY 1
Alef_Ricardo_
Resolver II
Resolver II

It seems that you are trying to create a measure in Power BI to calculate the return for a given period based on two slicers, one for Fund and one for date. However, the measure you have created always returns 1.

 

One possible reason for this issue could be that the SELECTEDVALUE function is not returning the expected value. The SELECTEDVALUE function returns the selected value when a single value is selected in the specified column, otherwise it returns the alternate result or blank if no alternate result is provided. You can try using the MAX or MIN function instead of SELECTEDVALUE to see if it resolves the issue.

 

Another possible reason could be that the FIRSTDATE function is not returning the expected value. The FIRSTDATE function returns the first date in the current context for the specified column of dates. Make sure that the column you are passing to the FIRSTDATE function contains dates and that the current context is set correctly.

If these suggestions do not resolve your issue, it would be helpful to have more information about your data model and the context in which you are using this measure. You may also want to consider posting your question on a Power BI forum or community where experts can provide more specific guidance.

 

Retorno =
VAR ValorInicial =
CALCULATE(
MIN(Resultados[Cota FIC]),
FILTER(
ALLSELECTED(Resultados),
Resultados[Data] = MIN(Resultados[Data])
)
)
VAR ValorFinal =
CALCULATE(
MAX(Resultados[Cota FIC]),
FILTER(
ALLSELECTED(Resultados),
Resultados[Data] = MAX(Resultados[Data])
)
)
RETURN
DIVIDE(ValorFinal, ValorInicial)

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.