cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
sivarajan21
Helper V
Helper V

How to use dax measure in legend field of stacked bar chart

Hi,

 

I am confused about how to use measure in legend colum.

@Ahmedx & @lbendlin helped me to create this  beautiful measures:

Accrual Source =
SWITCH (
TRUE (),
'Missing Calendar date_1'[Profile_efficient measure] <> BLANK (), "Profile",
'Missing Calendar date_1'[Direct_not efficient measu] <> BLANK (), "Direct",
'Missing Calendar date_1'[Target Unit] <> BLANK (), "Target",
'Missing Calendar date_1'[Half hour] <> BLANK (), "Half hour",
'Missing Calendar date_1'[Water] <> BLANK (), "Water"
)

But i am not able to drag this into legend column of stacked bar chart. Because of that chart shows like below(doesn't each source).

sivarajan21_1-1684604349662.png

 

I need to show in chart which source data come from that is Profile or Direct or Target.

Please find sample file in below link:

Missing Calendar fixed.pbix

 

The expected outcome for legend is:

sivarajan21_0-1684604186508.png

 

 

Please let me know if you need further details

 

 

Thanks in advance

@Ahmedx  @lbendlin @grantsamborn @Greg_Deckler @Ashish_Mathur 

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@sivarajan21 In general, to use a measure in that way, you need to use the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

I could drag that field to the legend.  See image below.  The month order is not correct but that was not your problem in the first place.

Untitled.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

Hi @Ashish_Mathur ,

 

The field you have dragged is from Missin Calendar table which should work.

But my question is I was not able to drag measure Accrual_Source in visual legend

 

Thanks

Greg_Deckler
Super User
Super User

@sivarajan21 In general, to use a measure in that way, you need to use the Disconnected Table Trick as this article demonstrates: https://community.powerbi.com/t5/Community-Blog/Solving-Attendance-with-the-Disconnected-Table-Trick...


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
Mastering Power BI 2nd Edition

DAX is easy, CALCULATE makes DAX hard...

Hi @Greg_Deckler ,

 

Thanks for this amazing article

Surely I will try this and get back to you if any issues

Now I will accept this as a solution

 

Many Thanks 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors