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.
I am trying to show the change in the [% of Fund] for each instrument in the portfolio from the earliest date in the filter period to the latest date in the filter period. So far I have
Change% = VAR MaxDate = CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) ) VAR MinDate = CALCULATE ( MIN ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) ) RETURN CALCULATE ( SUMX ( DataAllFunds, DataAllFunds[% of Fund] ), DataAllFunds[Date] = MaxDate ) - CALCULATE( SumX ( DataAllFunds ,DataAllFunds[% of Fund]), DataAllFunds[Date] = MinDate)
Plotting Instrument against %Change gives me the correct values.
But I want to add the change Column into my table which currently shows the holding for the Latest Date in the table and only the instruments classified as "Equity". Then my %Change becomes zero for everything.
Where am I going wrong?
Solved! Go to Solution.
It is the filter that affects the expected output. Try to add ALLEXCEPT to your measure. If it doesn't work, please upload a sample pbix file.
Change% = VAR MaxDate = CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) ) VAR MinDate = CALCULATE ( MIN ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) ) RETURN CALCULATE ( SUMX ( ALLEXCEPT ( DataAllFunds, DataAllFunds[InstrCode] ), DataAllFunds[% of Fund] ), DataAllFunds[Date] = MaxDate ) - CALCULATE ( SUMX ( ALLEXCEPT ( DataAllFunds, DataAllFunds[InstrCode] ), DataAllFunds[% of Fund] ), DataAllFunds[Date] = MinDate )
It is the filter that affects the expected output. Try to add ALLEXCEPT to your measure. If it doesn't work, please upload a sample pbix file.
Change% = VAR MaxDate = CALCULATE ( MAX ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) ) VAR MinDate = CALCULATE ( MIN ( 'Calendar'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) ) RETURN CALCULATE ( SUMX ( ALLEXCEPT ( DataAllFunds, DataAllFunds[InstrCode] ), DataAllFunds[% of Fund] ), DataAllFunds[Date] = MaxDate ) - CALCULATE ( SUMX ( ALLEXCEPT ( DataAllFunds, DataAllFunds[InstrCode] ), DataAllFunds[% of Fund] ), DataAllFunds[Date] = MinDate )
Thanks Eric! This is what I ended with.
Change%M = VAR MaxDate = CALCULATE ( MAX ( 'DataAllFunds'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) ) VAR MinDate = CALCULATE ( MIN ( 'DataAllFunds'[Date] ), ALLSELECTED ( 'Calendar'[Date] ) ) RETURN CALCULATE ( SUMX ( DataAllFunds, [Fund % M] ), DataAllFunds[Date] = MaxDate ) - CALCULATE( SumX ( DataAllFunds ,[Fund % M]), DataAllFunds[Date] = MinDate)
Where Fund % M is
Fund % M = VAR Fund = DISTINCT ( DataAllFunds[Fund] ) VAR TDate = MAX ( DataAllFunds[Date] ) RETURN DIVIDE ( CALCULATE ( SUM ( DataAllFunds[Market Value] ), DataAllFunds[Fund] = Fund, DataAllFunds[Date] = TDate ), CALCULATE ( SUM ( DataAllFunds[Market Value] ), FILTER ( ALL ( DataAllFunds ), DataAllFunds[Fund] = Fund && DataAllFunds[Date] = TDate ) ), 0 ) * 100
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 |
---|---|
112 | |
99 | |
73 | |
72 | |
49 |
User | Count |
---|---|
145 | |
109 | |
108 | |
90 | |
64 |