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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

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
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

Find out what's new and trending in the Fabric community.