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
Remmie0
Regular Visitor

Dynamic names in field parameters (Selectedvalue)

Hi community,

 

I am trying to get dynamic column names in my tables in a way that it always shows the Gross revenue for the selected year and the year before. 
I am using a field parameter and I have tried the below code (and max, last date etc etc) 

 

_DynamicMeasuresGrossRevenue =
{
    ("Gross Revenue " & SELECTEDVALUE('Calendar (Posting Date)'[Year]), NAMEOF('_Measures'[Gross Revenue]), 0),
    ("Gross Revenue " & SELECTEDVALUE('Calendar (Posting Date)'[Year])-1, 1)
}

But it won't show the selectedvalue in the report. 
I think this should have been one of the basic functionalities and I can't seem to get it working. 
I know I can change the names dynamically with current date and last month or current year last year etc, but I want the 'SELECTED' years and not only to compare against current year. https://www.youtube.com/watch?v=9_2m5Csr55c&t=186s&ab_channel=Hari%27sBI This video showed me how to change my name but not without selectedvalue (It is not my video or anyone I know, just an example that it should be possible)

I only found one other post about this in all posts online and it got no answer and over 100 views. https://stackoverflow.com/questions/75338705/using-selectedvalue-with-field-parameter-prior-period-t...

What I want to achieve is when I select 2022 to have the columns Gross Revenue 2022, Gross Revenue 2021 and all my other columns. When I select 2021 I expect to have Gross Revenue 2021, 2020 and all my others etc.

Right now it is showig as blank when I use selectedvalue, and while today, hardcoded values etc seem to work, max(Year), Selectedvalue(Year) do not seem to work. 
Remmie0_0-1680854898132.pngRemmie0_1-1680854941176.png

 

 


I can not share the actual data as it is sensitive, but I would like to be able to use dynamic names as I want to do this for revenue, sales quantity etc. The values do update and show selected year and last year, but the column name doesn't.


Gross revenue is defined as SUM(Gross Revenue)
Gross revenue last year is defined as 
_Gross Revenue LastYear =
VAR SelectedYear = SELECTEDVALUE('Calendar (Posting Date)'[Year])
RETURN

CALCULATE(
    [Gross Revenue],
    FILTER(
        ALL('Calendar (Posting Date)'),
        'Calendar (Posting Date)'[Year] >= SelectedYear - 1 && 'Calendar (Posting Date)'[Year] <+ SelectedYear
    )
)

If anyone could help me out it would be highly appreciated, 
Kind regards. 
22 REPLIES 22
Amerdeep007
Regular Visitor

Hi, i am having the same doubt regarding the use of the Function (SELECTEDVALUE) in field parameter.
The below is my Dax Code:

test =
VAR selectedyear= SELECTEDVALUE('DATE '[Year])
--VAR slicer= FORMAT((selectedyear),BLANK())

 

return
{
    (selectedyear, NAMEOF('Actuals_Sales Testing'[selected_year]), 0),
    (selectedyear-1 , NAMEOF('Actuals_Sales Testing'[selected_year-1 ), 1),
    ( selectedyear-2, NAMEOF('Actuals_Sales Testing'[selected_year-2]), 2),
    (selectedyear-1 vs selectedyear-2 , NAMEOF('Actuals_Sales Testing'[Prev % Diff YOY ]), 3),
    (selectedyear vs selectedyear-1, NAMEOF('Actuals_Sales Testing'[Curr % Diff YOY]), 4),
    ("3 Year CAGR tt", NAMEOF('Actuals_Sales Testing'[3 Year CAGR tt]), 5)
}
The required output:
if 2024 is selected in slicer,test should return like 
Screenshot_40.jpg
if 2023 is selected it should return like below
Screenshot_41.jpg
is there any possible way or just give the names as fixed?




oduc78
Regular Visitor

Hello, I've got a similar issue but I haven't been able to find a solution. I created a new post: SELECTEDVALUE doesn't work to add a dynamic header to Field Parameters. Maybe comparing similar problems can help us solve them, let me know.

Olivier.

Felipe_Matssu
Regular Visitor

Olá... Estava com o mesmo problema, consegui resolver criando uma medida da seguinte forma:

 

Nome_Título =
    SELECTCOLUMNS('Parâmetro de Campo",'Parâmetro de Campo'[Campo])
 
Como no filtro em que está o parâmetro já está configurado para seleção única, o resultado dessa medida mostra apenas o nome do coluna selecionada.
 
Espero que possa ajudar de alguma forma 😃
_____________________________________________________________
 

Hello... I had the same problem, I managed to solve it by creating a measure as follows:

 

Name_Title =SELECTCOLUMS('Field Parameter",'Field Parameter'[Field])

 

As in the filter where the parameter is already configured for single selection, the result of this measure only shows the name of the selected column.

 

I hope I can help in some way 😃

 

PS.: Traduzido pelo google
MMark
Regular Visitor

Hello, I tried to solve this also. I would say I find the answer - it is not possible in this way.

 

Reason - the parameter table is still a table, it is created with refresh of the dataset. At this point, it is no dynamic anymore. It can use the date, time or alternative result from selectedvalue { SELECTEDVALUE( table[column], alternative) }, but not the selected value itself, as there is any at that moment.

Ismail_Cinar
Frequent Visitor

I am also looking for a solution exactly for this case. SELECTEDVALUE returnes nothing when used in Field Parameters. Did you find something @Remmie0  @noverkamp ?

@lbendlin , man you don't need a sample data for this case. Just created a field parameter and put one measure inside. For example, put a measure named as "Net Sales". I assume you would have a YEAR table in your dataset. The idea is to change the measure display name based on a selected year. If you select 2023, the measure name must be "Net Sales 2023" or "Net Sales 2022" based on the selected value.  (But only in Field Parameter, no need to provide other workarounds)

Unfortunately not.. 

Remmie0
Regular Visitor

Hi, 

I have shown the sample output I would like to aquire. 

I want gross revenue 2022, gross revenue 2021 if I select year = 2022

I want gross revenue 2021, gross revenue 2020 if I select year = 2021 etc. 

I know the functions TODAY() and today - value works, but I want to do it on a selection based.

Can't help without sample data.

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

I've the same problem. Do you already have a solution?

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

YearLineEUR
2022A10
2022B20
2022C25
2023A14
2023D69
2023F50


Fact table:

noverkamp_0-1686205424864.png


Dimension Table:

noverkamp_1-1686205469352.png

 

OT_Year = 
DISTINCT(
    SELECTCOLUMNS(
        CALENDAR(
            DATE(2022, 1, 1),
            TODAY()
        ),
        "Year", FORMAT(year([Date]), "0")
    ))

 


Visual:

noverkamp_2-1686205595599.png


Dynamic_parameter_field_EUR:

noverkamp_3-1686205650323.png

Dynamic_parameter_field_EUR = 
VAR selected_year = SELECTEDVALUE(OT_Year[Year])
Return

{
    ("Year ("&selected_year&")", NAMEOF('Fact'[Measure_EUR]), 0)
}

 

 

Ovo je veoma korisno! Puno ti hvala!!

Hi, 

I had something similar but look it shows year () and not year (2022) for example. It looks like  selected year gets ignored and that was my issue too. 

 SELECTEDVALUE('Calendar (Posting Date)'[Year])-1 resulted in ' -1'

Kind regards,
Remco

Hi Remco, that's correct.
It shows Year () and not Year (2022)

That's unfortunately my issue, I would love the year to be shown, but as far as I am aware that is not possible to this date.

- is the OT_Year table joined or disconnected?  If it is joined then you don't need the dynamic field parameter.

lbendlin_1-1686230501981.png

 

 

lbendlin_0-1686230441746.png

 

- if you expect the user to always select exactly one year then make the slicer single select.

The data is an simple example. In my model I've several fields, so I need the dynamic field parameter. The question is, is this possible with 'selectedvalue'?

I have now posted this several times. I'll try one more time.

 

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...
Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

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.