cancel
Showing results for
Did you mean:
Resolver II

## Calculate with seleced value

Hi,

[Total] is a measure (a simple Sum(Revenue) )

Calendar is a calendar table. There is a relationship between the calendar table and the revenue table

This works:

``````Total this year =
VAR vYear = 2020
RETURN
CALCULATE([Total], 'Calendar'[Year] = vYear)``````

Gives me the correct number

But this doesn't:

``````Total this year =
VAR vYear = SELECTEDVALUE('Calendar'[Year])
RETURN
CALCULATE([Total], 'Calendar'[Year] = vYear)``````

The result of this is (BLANK)

I have a slicer where the user can select only one year, no multi select.

1 ACCEPTED SOLUTION
Super User IV

@whereismydata , first of all if they are related then

CALCULATE([Total])  should get the filter

or try like

Total this year =
VAR vYear = SELECTEDVALUE('Calendar'[Year])
RETURN
CALCULATE([Total], filter('Calendar','Calendar'[Year] = vYear))

or

Total this year =
VAR vYear = SELECTEDVALUE('Calendar'[Year])
RETURN
CALCULATE([Total], filter(all('Calendar'),'Calendar'[Year] = vYear))

Proud to be a Super User!

2 REPLIES 2
Resolver II

I was using filter(all ....) before, but it didn't work. Tried it again and now it works. Should call it a day 😄

Thank you for taking the time looking at my problem!

Best

Super User IV

@whereismydata , first of all if they are related then

CALCULATE([Total])  should get the filter

or try like

Total this year =
VAR vYear = SELECTEDVALUE('Calendar'[Year])
RETURN
CALCULATE([Total], filter('Calendar','Calendar'[Year] = vYear))

or

Total this year =
VAR vYear = SELECTEDVALUE('Calendar'[Year])
RETURN
CALCULATE([Total], filter(all('Calendar'),'Calendar'[Year] = vYear))

Proud to be a Super User!

Announcements