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

Does anyone know what's wrong with my DAX?

This is it:

 

Active Case Age = calculate(filter(incidents, incidents[Case Status] = "Active"), Year(TODAY()) - incidents[Case Created On].[Day])

 

An error keeps coming up:

 

The expression refers to multiple columns. Multiple columns cannot be converted to a scalar value.

 

 

I want to figure out the Age for Active Cases (which means tickets or incidents that occured) only instead of other cases that are resolved or canceled.  

 

4 REPLIES 4
v-cherch-msft
Employee
Employee

Hi @GenericUser1

 

You may also use MAX Function or SELECTEDVALUE Function for the [case created on] column to create the measure.

 

 

Regards,

Cherie

Community Support Team _ Cherie Chen
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Seward12533
Solution Sage
Solution Sage

Your calculate is not structured correctly.  . 

 

The first term needs to be the expression which should then be followed by your filter expression - and you probably don't need the explicit filter but that's not causing the issue.  Assuming your second term is meant to be what your calculating that does not appear to be what your trying to do.  YEAR(Today()) will return the YEAR of the current date. and the second term indents[Case Created On].[DAY] will return the DAY of the date it was created on so if case was created on 8/20/18 your expression would  be 2018-20 = 1998 which I doubt is what  you want.

 

Also rather than just subtracting dates I'd recommend DATEDIFF.  

 

So if you wanted the number of days from TODAY and the create date for active  cases try this.   

 

Active Case Age = calculate(DATEDIFFE(incidents[case created on],,TODAY(),DAY), incidents[Case Status] = "Active")

 

IF you wanted the age in weeks

 

Active Case Age = calculate(DATEDIFFE(incidents[case created on],,TODAY(),WEEK), incidents[Case Status] = "Active")

Thanks! But the DAX only returns measures not columns? Would I have to create some sort of measure for the DAX to accept the Created On column>

If you want as Measure then you need to aggregate the value.


Active Case Age = calculate(DATEDIFFE(AVERAGE(incidents[case created on]),TODAY(),DAY), incidents[Case Status] = "Active")

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.