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
sajal161292
Helper V
Helper V

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

 

Can someone please help me with it?

1 REPLY 1
v-shex-msft
Community Support
Community Support

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
If this post helps, please consider accept as solution to help other members find it more quickly.

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.