Codementor Events

Power BI – How to set default selection on card

Published Jul 07, 2020Last updated Jul 15, 2020

Power BI – How to set default selection on card

Say you have a table like the one below.
image.png

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).
image-1.png

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])
        )
) 

image.png

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

Discover and read more posts from Bennie Jay Guevarra
get started
post commentsBe the first to share your opinion
Show more replies