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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.

Top Solution Authors