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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
BZ_AF
Frequent Visitor

How do I detect the active calculation item of a calculation group for a measure?

Suppose in this example I have a calculation group for cumulative sum

 

BZ_AF_0-1701913592713.png

 

I would like to have a measure that can detect what the active calculation item is.

 

I notice that the Calculation Group can be accessed like a table in DAX. I create a measure to concatenate the measure names:

Detect CalcGroup = CONCATENATEX('CalcGroup Cumulative Sum', CONVERT( [Cumulative Sum Group], STRING), ",")

The card measure shows that it is working when both are not filtered out.

BZ_AF_2-1701913837304.png

 

 

However, when only one is filtered, an error is shown:

BZ_AF_3-1701913882503.png

 

 

I do not know why this is happening. As you can see in the DAX measure, I have purposely converted the [Cumulative Sum Group] column into a String just to see if this fixes the problem, but it does not. Also, it works fine for multiple values, but not for a single value. I was hoping to use this mechanism to detect which calculation group is active, is there any possibility of this working?

 

1 ACCEPTED SOLUTION
BZ_AF
Frequent Visitor

I have realized my error. The calculation item's calculation affects the measure that I am creating and it comes into play when a single calculation item is selected. A workaround is for each calculation item, if the SELECTEDMEASURENAME() equals to the measure name, return SELECTEDMEASURE().

View solution in original post

3 REPLIES 3
BZ_AF
Frequent Visitor

I have realized my error. The calculation item's calculation affects the measure that I am creating and it comes into play when a single calculation item is selected. A workaround is for each calculation item, if the SELECTEDMEASURENAME() equals to the measure name, return SELECTEDMEASURE().

Anonymous
Not applicable

Hi @BZ_AF ,

Based on my research, it seems that the issue you are facing is due to the fact that the CONCATENATEX function requires at least two arguments to work properly. When only one value is filtered, the function is unable to concatenate the values and throws an error.

One possible solution to this issue is to use the SELECTEDVALUE function instead of the CONVERT function. The SELECTEDVALUE function returns the value of the specified column when there is only one distinct value in the filter context, and returns a blank when there are multiple distinct values. 

Detect CalcGroup =
IF (
HASONEVALUE ( 'CalcGroup Cumulative Sum'[Cumulative Sum Group] ),
SELECTEDVALUE ( 'CalcGroup Cumulative Sum'[Cumulative Sum Group] ),
BLANK ()
)

This measure checks if there is only one distinct value in the filter context. If there is, it returns the value of the ‘Cumulative Sum Group’ column. If there are multiple distinct values, it returns a blank.

 

 

How to Get Your Question Answered Quickly 

 

If it does not help, please provide more details with your desired output and pbix file without privacy information (or some sample data) .

 

Best Regards
Community Support Team _ Rongtie

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

 

 

 

Unfortunately this solution doesn't seem to work. 

 

I copied and pasted your measure and put it in a card. It shows (Blank) if >1 is selected. But if 1 is selected the same error occurs.

BZ_AF_1-1702279195774.png

 

BZ_AF_2-1702279205276.png

 

 

How do I attach a .pbix file? Trying to attach it here gives an error:

BZ_AF_0-1702279150205.png

 

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Feb2025 Sticker Challenge

Join our Community Sticker Challenge 2025

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

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