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.
Jan | Feb | March | April | May | June | July | Aug | Sept | Oct | Nov | Dec | Year |
|
|
|
|
|
|
|
|
|
|
|
|
|
Solved! Go to Solution.
HI @Absalon29,
You can try to use below formula to achieve your requirement:
Measrue:
Result = VAR maxdate = MAXX ( FILTER ( ALL ( EMCD ), YEAR ( [Date] ) = MAX ( DimDate[Year] ) ), [Date] ) VAR current_dec = SUMX ( FILTER ( ALL ( EMCD ), FORMAT ( [Date], "yyyy/mm" ) = FORMAT ( maxdate, "yyyy/mm" ) ), [Absalon EM Corporate Debt SICAV NAV] ) VAR temp = SUMX ( FILTER ( ALL ( EMCD ), FORMAT ( [Date], "yyyy/mm" ) = FORMAT ( DATE ( YEAR ( maxdate ) - 1, MONTH ( maxdate ), 1 ), "yyyy/mm" ) ), [Absalon EM Corporate Debt SICAV NAV] ) VAR previous_dec = IF ( temp <> BLANK (), temp, LOOKUPVALUE ( EMCD[Absalon EM Corporate Debt SICAV NAV], EMCD[Date], MINX ( FILTER ( ALL ( EMCD ), [Absalon EM Corporate Debt SICAV NAV] <> BLANK () ), [Date] ) ) ) RETURN IF ( MAX ( [Absalon EM Corporate Debt SICAV NAV] ) <> BLANK (), IF ( current_dec / previous_dec <> BLANK (), current_dec / previous_dec - 1 ) )
Notice: if your data contains any privacy data, please do mask sensitive data before sharing.
Regards,
Xiaoxin Sheng
Ashish thanks for your help. You have supplied a spreadsheet with the calculation which I already have. What I was looking to do was work out the syntax in Dax to reproduce the excel formula. Running the calculation in excel is straightforward, running it in Dax requires a lot more knowledge of the language eg the use of Earier, etc. I'm not there yet, but thanks for your help.
I'm trying to adapt this code to a table which has a half dozen funds, so I tried adding a filter on the name of the funds, but I got this error:
Calculation error in measure 'AllMeasures'[Result]: A table of multiple values was supplied where a single value was expected.
So I modified code like this:
VAR maxdate =
MAXX (
FILTER (
FILTER(PortfolioPerf, PortfolioPerf[DisplayName] = "Growth"),
YEAR ( [PerformanceDate] ) = MAX ( DateDim[Year] ) ),
[PerformanceDate]
)
Do I need to break the table up one per fund, or can I add a filter to this code like I'm attempting?
Hi,
Try this measure
VAR maxdate =
MAXX (
FILTER (
CALCULATETABLE(PortfolioPerf, PortfolioPerf[DisplayName] = "Growth"),
YEAR ( [PerformanceDate] ) = MAX ( DateDim[Year] ) ),
[PerformanceDate]
)
I tried changing from Filter to CalculateTable and I got the same errror:
Calculation error in measure 'AllMeasures'[OneYearRateForGrowth]: A table of multiple values was supplied where a single value was expected.
And I suppose I can share the whole thing, but it should look very similar I believe we have five stategies in this basket each can be distinquished by a unique name or number.
OneYearRateForGrowth =
VAR maxdate =
MAXX (
FILTER (
CALCULATETABLE(PortfolioPerf, PortfolioPerf[DisplayName] = "Growth"),
YEAR ( [PerformanceDate] ) = MAX ( DateDim[Year] ) ),
[PerformanceDate]
)
VAR current_dec =
SUMX (
FILTER (
CALCULATETABLE(PortfolioPerf, PortfolioPerf[DisplayName] = "Growth"),
FORMAT ( [PerformanceDate], "yyyy/mm" ) = FORMAT ( maxdate, "yyyy/mm" )
),
[CummulativeIndex]
)
VAR temp =
SUMX (
FILTER (
CALCULATETABLE(PortfolioPerf, PortfolioPerf[DisplayName] = "Growth"),
FORMAT ( [PerformanceDate], "yyyy/mm" )
= FORMAT ( DATE ( YEAR ( maxdate ) - 1, MONTH ( maxdate ), 1 ), "yyyy/mm" )
),
[CummulativeIndex]
)
VAR previous_dec =
IF (
temp <> BLANK (),
temp,
LOOKUPVALUE (
PortfolioPerf[CummulativeIndex],
PortfolioPerf[PerformanceDate], MINX (
FILTER ( CALCULATETABLE(PortfolioPerf, PortfolioPerf[DisplayName] = "Growth")
, [CummulativeIndex] <> BLANK () ),
[PerformanceDate]
)
)
)
RETURN
IF (
MAX ( PortfolioPerf[CummulativeIndex] ) <> BLANK (),
IF ( current_dec / previous_dec <> BLANK (), current_dec / previous_dec - 1 )
)
Thanks for the help, but this is kinda not priority number one, so I just quickly tried your code and I keep getting that error.
Thanks I will, my boss actually changed his mind, but yeah we have this basic problem but multiple return streams in the same table. So I thought I could break it up or filter. My DAX was never the best and probably is rusty, thanks a lot.
Hi @Absalon29,
You have started another thread with the same question. I have answered your question in that thread. Download my solution from here.
Ashish thanks for your help. You have supplied a spreadsheet with the calculation which I already have. What I was looking to do was work out the syntax in Dax to reproduce the excel formula. Running the calculation in excel is straightforward, running it in Dax requires a lot more knowledge of the language eg the use of Earier, etc. I'm not there yet, but thanks for your help.
Hi,
I have solved the problem using only and only DAX i.e. PowerPivot in MS Excel. Please check the file at that link. This entire model can be taken to PowerBI desktop with just one click.
HI @Absalon29,
You can try to use below formula to achieve your requirement:
Measrue:
Result = VAR maxdate = MAXX ( FILTER ( ALL ( EMCD ), YEAR ( [Date] ) = MAX ( DimDate[Year] ) ), [Date] ) VAR current_dec = SUMX ( FILTER ( ALL ( EMCD ), FORMAT ( [Date], "yyyy/mm" ) = FORMAT ( maxdate, "yyyy/mm" ) ), [Absalon EM Corporate Debt SICAV NAV] ) VAR temp = SUMX ( FILTER ( ALL ( EMCD ), FORMAT ( [Date], "yyyy/mm" ) = FORMAT ( DATE ( YEAR ( maxdate ) - 1, MONTH ( maxdate ), 1 ), "yyyy/mm" ) ), [Absalon EM Corporate Debt SICAV NAV] ) VAR previous_dec = IF ( temp <> BLANK (), temp, LOOKUPVALUE ( EMCD[Absalon EM Corporate Debt SICAV NAV], EMCD[Date], MINX ( FILTER ( ALL ( EMCD ), [Absalon EM Corporate Debt SICAV NAV] <> BLANK () ), [Date] ) ) ) RETURN IF ( MAX ( [Absalon EM Corporate Debt SICAV NAV] ) <> BLANK (), IF ( current_dec / previous_dec <> BLANK (), current_dec / previous_dec - 1 ) )
Notice: if your data contains any privacy data, please do mask sensitive data before sharing.
Regards,
Xiaoxin Sheng
What if the NAV column was based on a measure?
Is it possible to make the calculation?
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 |
---|---|
115 | |
100 | |
88 | |
68 | |
61 |
User | Count |
---|---|
152 | |
120 | |
102 | |
87 | |
68 |