Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

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.

Reply
whereismydata
Resolver IV
Resolver IV

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
Super User

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

View solution in original post

2 REPLIES 2
whereismydata
Resolver IV
Resolver IV

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
Super User

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

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.