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
_Kevin_
Helper I
Helper I

Use a measure result as a date

Hi

 

I have 2 measures as follows:

 

a) CurrentMonth = MAX((Info[Reporting Month])) - It renders "2020/04/30" and
b) HCCurrentMonth = CALCULATE(SUM(HC_ACT[Headcount]),HC_ACT[TIME] = DATE(2020,04,30))
 
I would like to use the first measure to replace the date in the second measure, but this does not work, and gives the error "A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression."
 
How can I achieve the intended result?
 
thank you
Kevin
1 ACCEPTED SOLUTION
az38
Community Champion
Community Champion

Hi @_Kevin_ 

try 

HCCurrentMonth = 
var _CurrentMonth = MAX((Info[Reporting Month]))
RETURN

CALCULATE(SUM(HC_ACT[Headcount]),HC_ACT[TIME] = _CurrentMonth )

or

HCCurrentMonth = CALCULATE(SUM(HC_ACT[Headcount]),FILTER(HC_ACT, HC_ACT[TIME] = SELECTEDVALUE([CurrentMonth]) ))

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

View solution in original post

5 REPLIES 5
Tahreem24
Super User
Super User

Hi Kevin,

HCCurrentMonth = CALCULATE(SUM(HC_ACT[Headcount]), FILTER(HC_ACT,HC_ACT[TIME] = MAX(HC_ACT[TIME])))

 

 

Don't forget to give thumbs up and accept this as a solution if it helped you!!!

Please take a quick glance at newly created dashboards : Restaurant Management Dashboard , HR Analytics Report , Hotel Management Report, Sales Analysis Report , Fortune 500 Companies Analysis , Revenue Tracking Dashboard
az38
Community Champion
Community Champion

Hi @_Kevin_ 

try 

HCCurrentMonth = 
var _CurrentMonth = MAX((Info[Reporting Month]))
RETURN

CALCULATE(SUM(HC_ACT[Headcount]),HC_ACT[TIME] = _CurrentMonth )

or

HCCurrentMonth = CALCULATE(SUM(HC_ACT[Headcount]),FILTER(HC_ACT, HC_ACT[TIME] = SELECTEDVALUE([CurrentMonth]) ))

do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi @az38 

Thanks, the first option works great.

 

I would have preferred to use the second option but I cannot use a measure in the SELECTEDVALUE and get  "Parameter is not the correct type"

 

Regards

Kevin

 

az38
Community Champion
Community Champion

@_Kevin_ 

try MAX() instead of SELECTEDVALUE() as @Tahreem24  mentioned


do not hesitate to give a kudo to useful posts and mark solutions as solution
LinkedIn

Hi @az38 

 

I don't need either, I have now put the measure straight after "=" and it works too. 

 

regards

Kevin  

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.