cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
whereismydata
Resolver II
Resolver II

Calculate with seleced value

Hi,

 

can somebody please help me out here.

[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.

 

Thank you in advance

1 ACCEPTED SOLUTION
amitchandak
Super User IV
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))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

2 REPLIES 2
whereismydata
Resolver II
Resolver II

Hi @amitchandak 

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

 

amitchandak
Super User IV
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))



Did I answer your question? Mark my post as a solution! Appreciate your Kudos!!
Dashboard of My Blogs !! YouTube Channel !! Connect on Linkedin

Proud to be a Super User!

View solution in original post

Helpful resources

Announcements
PBI User Groups

Welcome to the User Group Public Preview

Check out new user group experience and if you are a leader please create your group!

MBAS on Demand

Microsoft Business Applications Summit sessions

On-demand access to all the great content presented by the product teams and community members! #MSBizAppsSummit #CommunityRocks

MBAS Attendee Badge

Claim Your Badge & Digital Swag!

Check out how to claim yours today!

Top Solution Authors
Top Kudoed Authors