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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
BobKoenen
Helper IV
Helper IV

Extract name calculation item from calculation group

Hi all,

 

I have set up a calculation group using tabular Editor. Users of the report can select one out of 4 measures to evaluate the page. Now I would like to extract the name of the calculation item they choose to use as a dynamic title. 

 

So if user selects "Sales amount" from the calculation group slicer on the raport page I want the Month overview to say:

Month overview for Sales amount. 

If the user selected [Margin]. It should say [Month overview for Margin]. 

 

I was able to do this using ="Month overview"& SELECTEDVALUE('table'[column]) on a normal tabel but I cannot seem to get it to work with a calculation group table. Do any of you have an Idea?

1 ACCEPTED SOLUTION
v-shex-msft
Community Support
Community Support

Hi @BobKoenen,

As the document said, these functions are based on the calculation groups. How did you calculate group settings? Did you confirm you have correctly configured these fields and properties?

If not, you can take a look at the following blog that mentioned about create calculate groups in power bi dekstop:

Creating Calculation Groups in Power BI Desktop 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

View solution in original post

10 REPLIES 10
BarnabasToth
Resolver I
Resolver I

@BobKoenen I had the exact same issue, creating a conditionally formatted title for a visual.

Inspired by a SQLBI video one way to solve this is to:

1) Create a disconnected table, referencing your Calculation Group (in this example 'Internal Calc Group').

 

Disconnected table = 
-- This is the disconnected table available for the user (put 'Disconnected table'[Measure] field in the slicer).
SELECTCOLUMNS(
    'Internal Calc Group',
    "Measure",'Internal Calc Group'[Name],
    "Ordinal",'Internal Calc Group'[Ordinal]
)

 

 

2) Use a Generic measure in your visual as Values.
This Generic measure will be replaced based on the slicer selection, therefore it behaves as if a Calculation Group were applied on it ('Disconnected table'[Measure] values are treated as Calculation Items of 'Internal Calc Group'), plus - since the field in the slicer is from a regular table - its value can be captured by SELECTEDVALUE.

 

Generic measure := 
-- To be replaced according to your Calculation Items.
CALCULATE(
    COALESCE([MeasureInYourCalcItem1],[MeasureInYourCalcItem2],[MeasureInYourCalcItem3]),
    TREATAS(
        VALUES('Disconnected table'[Measure]),
        'Internal Calc Group'[Name]
    )
)

 

 

3) Create a measure for the dynamic title.

 

Dynamic title := "Month overview for " & SELECTEDVALUE('Disconnected table'[Measure])

 


 

spencerm3
Frequent Visitor

So I've come up with a terrible work around. 
The new smart text functions of a text box can return the value we're looking for. So visually you can replace your chart title with a text box using smart text. 

Thanks, I had the same issues that the resut from the calculation would come up instead of the name. Its not a terrible work around for me, it did the trick 🙂

The pro is that it got me to learn a little more about Smart Text. 
the con is that the font I use for the other chart titles (Segoi UI I think) isn't available in Smart text. And it's the Power BI default!

JSEarich
Regular Visitor

I have the same problem.  SelectedValue, SelectedMeasure, SelectedMeasureName all result in two returns -- the actual result of the measure (numeric or percentage) or it returns the name of the measure "Selected KPI" that contains the SelectMeasure() as part of the calc group. But I can never get to the actual name of the caclulate item or even the name of the measure associated with the calculated item.

v-shex-msft
Community Support
Community Support

Hi @BobKoenen,

As the document said, these functions are based on the calculation groups. How did you calculate group settings? Did you confirm you have correctly configured these fields and properties?

If not, you can take a look at the following blog that mentioned about create calculate groups in power bi dekstop:

Creating Calculation Groups in Power BI Desktop 

Regards,

Xiaoxin Sheng

Community Support Team _ Xiaoxin
If this post helps, please consider accept as solution to help other members find it more quickly.

How do you return a string with the name of an item in the calculation group?  Purpose would be to use in a dynamic chart title. 

lbendlin
Super User
Super User

I believe this is what you are looking for: SELECTEDMEASURENAME function (DAX) - DAX | Microsoft Docs

@lbendlin  I thought so to but if I use 

measure = SELECTEDMEASURENAME()  

it gives me the value of the measure and not the name in a string

Agree with BobKoenen.  When using Selected Measure Name, you get the name of the measure that is dragged into the values area of the chart.  In my case, I've followed the example at the below link.  When I use Selectedmeasurename all I get is "Selected Chart Item" which is the name of the measure item I created in Tabular Editor.  What I want is the name of the Calculation item to return as a string so that I can use that string as the title of the chart.  Thus, when I change my slicer to "Revenue" the chart title changes to say "Revenue".

https://exceleratorbi.com.au/dynamic-formatting-of-switch-measures/

 

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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