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 dateJoin 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.
Hi everyone. I am working on a Power BI report where I added a Calculation Group for 10 various time intelligence calculations (MTD, YTD, QTD, etc...). The first of which is simply:
Current = SELECTEDMEASURE()
To test my time intelligence calculations, I added a Matrix visual to my report.
In the Rows I added Month from my Date dimension.
Time Calculations from my Calc Group to Columns
A simple measure "Total Sales" defined as Total Sales = SUM(Fact_Sales[Sales Amount]).
Shortly after I drop those items into the Matrix, I get an error:
Error fetching data for this visual
Cannot convert value 'Current' of type Text to type Number
I don't see where I can specify a data type for this calculation group item. What am I missing here?
Solved! Go to Solution.
Hi @JeffPtak - you can use the ISSELECTEDMEASURE function to apply the calculation group only to numerical measures:
Current =
IF(
ISSELECTEDMEASURE([Total Sales]),
SELECTEDMEASURE(),
BLANK()
)
it limits the scope of the calculation group item to the intended measures (e.g., Total Sales). hope this helps
Proud to be a Super User! | |
Hi All,
Firstly rajendraongole1 thank you for your solution!
And @JeffPtak ,
It looks like you're not familiar with this function, no matter, I'll give you a detailed answer:
SELECTEDMEASURE() is a special function in Power BI that returns the currently selected metric (e.g. total sales, profit, etc.). When you are working with calculation groups, SELECTEDMEASURE() will help you find the metric you selected in the report and then perform a calculation on it.
For example, if you select the measure Total Sales in the Values area of the Matrix, SELECTEDMEASURE() automatically returns the value of Total Sales.
If you select another measure, such as Total Profit, then SELECTEDMEASURE() will return the value of Total Profit.
The error you are getting is usually because SELECTEDMEASURE() is not correctly recognizing the metric you have selected, or the types of metrics you are using in the Matrix table do not match.
Here are some suggestions I hope you find useful:
1. Make sure you have selected the correct metric (e.g. Total Sales) in the “Values” area of the Matrix table. If the metric is not selected correctly, SELECTEDMEASURE() will not return a numeric value.
Ensure that the metric in the Calculation group is of numeric type: if you are using SELECTEDMEASURE(), it should return a numeric value (such as Sales Amount), not text. If it returns text, Power BI reports an error.
2. Test SELECTEDMEASURE(): You can create a simple test formula to confirm that SELECTEDMEASURE() is working properly, like this:
Test Measure = SELECTEDMEASURE()
If it returns text or blanks, you may need to adjust the context or metric definition.
3.If there is a problem with SELECTEDMEASURE(), you can check its value with IF():
Test Measure = IF(ISBLANK(SELECTEDMEASURE()), 0, SELECTEDMEASURE())
If the metric is not checked, it returns 0.
In general SELECTEDMEASURE() calculates based on the metrics you have selected in the report, and it will return an error if the metrics are not selected correctly, or if there is a problem with the context setting. Make sure that your calculation groups and metrics are set up correctly, and that the value returned is of numeric type.
SELECTEDMEASURE function (DAX) - DAX | Microsoft Learn
Hope it helps!
Best regards,
Community Support Team_ Tom Shen
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Not sure what was going on. I recreated the Calc Group and now everything is working just fine.
Not sure what was going on. I recreated the Calc Group and now everything is working just fine.
That didn't work. Got the same error.
I am new to calculation groups. Can you explain to me how the Calc Group knows what the "Selected Measure" is?
Hi All,
Firstly rajendraongole1 thank you for your solution!
And @JeffPtak ,
It looks like you're not familiar with this function, no matter, I'll give you a detailed answer:
SELECTEDMEASURE() is a special function in Power BI that returns the currently selected metric (e.g. total sales, profit, etc.). When you are working with calculation groups, SELECTEDMEASURE() will help you find the metric you selected in the report and then perform a calculation on it.
For example, if you select the measure Total Sales in the Values area of the Matrix, SELECTEDMEASURE() automatically returns the value of Total Sales.
If you select another measure, such as Total Profit, then SELECTEDMEASURE() will return the value of Total Profit.
The error you are getting is usually because SELECTEDMEASURE() is not correctly recognizing the metric you have selected, or the types of metrics you are using in the Matrix table do not match.
Here are some suggestions I hope you find useful:
1. Make sure you have selected the correct metric (e.g. Total Sales) in the “Values” area of the Matrix table. If the metric is not selected correctly, SELECTEDMEASURE() will not return a numeric value.
Ensure that the metric in the Calculation group is of numeric type: if you are using SELECTEDMEASURE(), it should return a numeric value (such as Sales Amount), not text. If it returns text, Power BI reports an error.
2. Test SELECTEDMEASURE(): You can create a simple test formula to confirm that SELECTEDMEASURE() is working properly, like this:
Test Measure = SELECTEDMEASURE()
If it returns text or blanks, you may need to adjust the context or metric definition.
3.If there is a problem with SELECTEDMEASURE(), you can check its value with IF():
Test Measure = IF(ISBLANK(SELECTEDMEASURE()), 0, SELECTEDMEASURE())
If the metric is not checked, it returns 0.
In general SELECTEDMEASURE() calculates based on the metrics you have selected in the report, and it will return an error if the metrics are not selected correctly, or if there is a problem with the context setting. Make sure that your calculation groups and metrics are set up correctly, and that the value returned is of numeric type.
SELECTEDMEASURE function (DAX) - DAX | Microsoft Learn
Hope it helps!
Best regards,
Community Support Team_ Tom Shen
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi @JeffPtak - you can use the ISSELECTEDMEASURE function to apply the calculation group only to numerical measures:
Current =
IF(
ISSELECTEDMEASURE([Total Sales]),
SELECTEDMEASURE(),
BLANK()
)
it limits the scope of the calculation group item to the intended measures (e.g., Total Sales). hope this helps
Proud to be a Super User! | |
Check out the July 2025 Power BI update to learn about new features.
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
User | Count |
---|---|
62 | |
61 | |
55 | |
38 | |
26 |
User | Count |
---|---|
85 | |
60 | |
45 | |
41 | |
39 |