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

Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now

Reply
Anonymous
Not applicable

Dynamic Chart based on Variable field

Hello,

 

As a Qlikview developer I find myself facing various difficulties with Power BI because I lost all my bearings.

 

Maybe my method is not the good one so please, let me know the best practice...

 

I created 2 tables by entering data :

PERIOD : Period

KPI : KPI

In the Period table I have the values MTD, QTD, YTD

In the KPI table I have different KPIs : IMC, IMG, Sales...

 

Then I have 2 slices, one for the period and the other with KPIs.

 

And finally, I would like to make a pie chart with in values the concatenation ok KPI and period which is an amount existing in a FACT table, like "IMC YTD" or "IMG QTD"... depending on what the user has selected.

 

So I tried to make a measure like this :

KPI Variable = 
var KPISelected = SELECTEDVALUE('KPI'[KPI])
var PeriodSelected = SELECTEDVALUE(PERIOD[Period])
return CALCULATE(KPISelected &" " & PeriodSelected)

But it juste returns the name of the field "IMC YTD", not the value...

How can I make the formula interpret the variable as a field and not as a text???

 

Thanks for help

1 REPLY 1
v-juanli-msft
Community Support
Community Support

Hi @Anonymous

Assume your fact table as below

7.png

add columns in the pie chart as above, go to "Format" pane, turn on "details label", select "Data value" for "Label style", in this way it show amount values instead of name of the field "IMC YTD".

 

create measures in fact table

Measure = SELECTEDVALUE('KPI'[KPI])&" "&SELECTEDVALUE(Period[Period])

Measure 2 = IF([Measure]=MAX('FACT'[Merged]),1,0)

8.png

 

remove all columns from the table visual but keep "merged" column

then add [Measure2] in the visual level filter in the table visual, select "show items when value is 1"

click on the cell on the table visual

9.png

 

Best Regards

Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

Share feedback directly with Fabric product managers, participate in targeted research studies and influence the Fabric roadmap.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.