cancel
Showing results for
Did you mean:
Member

## need to calculate a measure for counting the parts

Hi,

I am facing an issue while trying to calculate the total number of parts which will fall short within next 15 days.

I have created a new date column as:

15 days =
var x = today()+15
var y = if('Calendar'[new_date]<=x,'Calendar'[new_date],BLANK())
return y

I have created this measure as:

ShortageCount_15 =
var itemName = FIRSTNONBLANK(Shortages[name],Shortages[name])
var x = if('Shortages'[Total]<0,CALCULATE(SELECTEDVALUE('Calendar'[new_date]),FILTER('Calendar','Calendar'[Date]<=max('Calendar'[15 days]))))
var y = DATEDIFF(TODAY(),x,DAY)
RETURN
CALCULATE(
count(Shortages[item_segments]),
filter(Shortages,y <=15 &&
Shortages[name] = itemName
))

I earlier worked upon creating the measure for calculating the parts that will fall short as of today:

ShortageCount =
var itemName = FIRSTNONBLANK(Shortages[name],Shortages[name])
RETURN
CALCULATE(
count(Shortages[item_segments]),
filter(Shortages,Shortages[Shortage day] = -1 &&
Shortages[name] = itemName
))

Community Support Team

## Re: need to calculate a measure for counting the parts

HI @sajal161292,

Does 'Shortage day' means a measure with variable calculate formulas?  If this is a case, I'd like to suggest you to take a look at following links:

Optimizing DAX expressions involving multiple measures

Order of Evaluation in CALCULATE Parameters

Variables in DAX

AFAIK, if you nested use multiple measure for variable formulas who has particulate filters, it may not works properly at all row contents level.(for total row level, it may calculate with different result than you wanted)

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin Sheng
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

For learning resources/Release notes, please visit: | |