Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin 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.
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!
Solved! Go to Solution.
Read about Calculation Groups.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
10 | |
9 | |
8 | |
8 | |
7 |
User | Count |
---|---|
13 | |
12 | |
11 | |
11 | |
8 |