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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
pablom1
New Member

Use measures as functions

Hello, 

 

I'm new in Power BI. My question is if you can use a measure as a function with parameters. 

We have several measures with the same structure like:

Sum of Cars = 
var _NumberofItems = count(Car_ID)

var _NumberofUnvalidItems = CALCULATE(Count(Car_ID), 'Test'[Status] = "20000", ALLSELECTED())

var _NumberofNextItems = CALCULATE(Count(Car_ID), 'Next'[Status] = "90000", ALLSELECTED())

return _NumberofItems - _NumberofUnvalidItems + _NumberofNextItems

 

Our problem is that we have Cars, Motorbikes, Bikes, Vans.... and always the same measure structure. 

Is it possible to use something like this:

SumofItems= 
var _NumberofItems = count(<ITEM_ID>)

var _NumberofUnvalidItems = CALCULATE(Count(<ITEM_ID>), 'Test'[Status] = "20000", ALLSELECTED())

var _NumberofNextItems = CALCULATE(Count(<ITEM_ID>), 'Next'[Status] = "90000", ALLSELECTED())

return _NumberofItems - _NumberofUnvalidItems + _NumberofNextItems

and then call the function in a new measure:

Sum of Cars = SumofItems(Car_ID)
Sum of Bikes = SumofItems(Bike_ID)

 

If something changes, i only have to change the measure SumofItems. 

 

Thank you!

 

 

 

1 ACCEPTED SOLUTION
lbendlin
Super User
Super User

Read about Calculation Groups.

View solution in original post

1 REPLY 1
lbendlin
Super User
Super User

Read about Calculation Groups.

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.