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

Level up your Power BI skills this month - build one visual each week and tell better stories with data! Get started

Reply
garluc93
Frequent Visitor

How can I do a chart in Power BI using a measure as label?

This is the sample pbix I have done .This is the output I would obtain  

im2.png

I would obtain the number of customers for each month with the label defined in the measure m-mark = IF([sumlast3months]=3;"Gold"; IF([sumlast3months]=2;"Silver"; IF([sumlast3months]=1;"Bronze"; IF([sumlast3months]=0;"NotBuyer";BLANK())))) In the original file I have a label "New" too but it's expensive to add an other table. Do you have an idea?

1 ACCEPTED SOLUTION
sturlaws
Resident Rockstar
Resident Rockstar

Hi @garluc93,

 

since you cannot have a measure as a legend, you need to create a small table with the values you need on the legend. And then create a measure like this:

m-mark2 = 
var _tmp = ADDCOLUMNS(VALUES(data2[Customer Number]);"SL3MO";[sumlast3months_v2])
var _mk = SELECTEDVALUE(Marks[Mark])
return
SWITCH(
    TRUE();
    _mk="Gold";COUNTROWS(FILTER(_tmp;[SL3MO] = 3));
    _mk="Silver";COUNTROWS(FILTER(_tmp;[SL3MO] = 2));
    _mk="Bronze";COUNTROWS(FILTER(_tmp;[SL3MO] = 1 ));
    _mk="notBuyer";COUNTROWS(FILTER(_tmp;[SL3MO] = 0 ));
    blank())

 

sample

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

View solution in original post

3 REPLIES 3
sturlaws
Resident Rockstar
Resident Rockstar

Hi @garluc93,

 

since you cannot have a measure as a legend, you need to create a small table with the values you need on the legend. And then create a measure like this:

m-mark2 = 
var _tmp = ADDCOLUMNS(VALUES(data2[Customer Number]);"SL3MO";[sumlast3months_v2])
var _mk = SELECTEDVALUE(Marks[Mark])
return
SWITCH(
    TRUE();
    _mk="Gold";COUNTROWS(FILTER(_tmp;[SL3MO] = 3));
    _mk="Silver";COUNTROWS(FILTER(_tmp;[SL3MO] = 2));
    _mk="Bronze";COUNTROWS(FILTER(_tmp;[SL3MO] = 1 ));
    _mk="notBuyer";COUNTROWS(FILTER(_tmp;[SL3MO] = 0 ));
    blank())

 

sample

 

Cheers,
Sturla

If this post helps, then please consider Accepting it as the solution. Kudos are nice too.

Hi @sturlaws , you're precious. Do you have an idea to see New clients as the customer numbers that buy for the first time in the month visualized? I have done a measure but I'm not sure what it does

 

 

m-New = 
VAR GROUPDATA= GROUPBY(Test;Test[Customer Number];Test[datalink];"FDT";MINX(CURRENTGROUP();Test[datalink]))
var _mk = SELECTEDVALUE(Marks[Mark])
RETURN
SWITCH(
    TRUE();
    _mk="New";COUNTROWS(FILTER(GROUPDATA;[FDT]>=FIRSTDATE(TimeIntelligence[Date])));
    blank())

 

 

 

I have added a column revenue and this measure that looks function in your switch

 

NewCustomers = 
COUNTROWS(FILTER(ADDCOLUMNS(VALUES(Test[revenue]);"PreviousRevenue";CALCULATE(COUNTROWS(Test);FILTER(ALL(TimeIntelligence);TimeIntelligence[Date]<MIN(TimeIntelligence[Date]))));[PreviousRevenue]=0))

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

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

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.