Power BI is turning 10! Tune in for a special live episode on July 24 with behind-the-scenes stories, product evolution highlights, and a sneak peek at what’s in store for the future.
Save the dateEnhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.
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.
User | Count |
---|---|
22 | |
11 | |
8 | |
6 | |
6 |
User | Count |
---|---|
25 | |
12 | |
11 | |
7 | |
6 |