Power BI – How to set default selection on card
Say you have a table like the one below.
It is a Company’s Gross Profit on YTD and you want to display it in a graph with a year selection and a card to display the value (like the one below).
The card shows the sum of all the Gross Profit which is wrong because the it is YTD. To correct this, we are going to add the measure below.
Gross Profit = CALCULATE(SUM(GrossProfit[GrossProfit]),
FILTER(
GrossProfit,GrossProfit[Year] = MAX(GrossProfit[Year])
)
)
What this does is it calculates the sum of Gross Profit with year as its filter. When no Year is selected, the MAX function will get highest year and when a year is selected, the MAX function will return what YEAR is currently selected.
Originally published on acedbi.wordpress.com