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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
JUANROVALETTI
Frequent Visitor

How to use a measure as legend

Well, to better understand the context, let me explain the situation. My company provided support in obtaining the data, transforming it, and finally creating connected tables using direct query, which will update by fetching data directly from SAP.

 

The problem is that, as we know, direct query has many limitations, especially regarding the use of DAX for column aggregation and others. In the development of my report with this data, I managed quite well using measures until a need arose that I couldn't solve, despite trying many different approaches.

 

Without going into detail, the data table I mentioned is about SAP purchase order requests, and it contains key information in each row, such as:

- Request number

- Request position

- Assigned employee ID

- Request creation date

- Purchase order creation date

- Purchase order number

...among others.

 

The important thing and my goal are to use a measure or field parameter to segment the different rows based on their treatment days. In other words, each row should perform the operation DATEDIFF("request creation date", "purchase order creation date", days). Based on this result, it should return a category, for example, between 0-15 days, then between 16-30 days, and so on...

 

Additionally, there are rows that do not have a "purchase order creation date," so they should be segmented differently using DATEDIFF("request creation date", "TODAY", days). These should be categorized similarly to the previous ones, and they represent the non-concluded lines.

 

The final goal and what I need to achieve is to use this measure or parameter as a legend in visuals or on the X-axis for differentiation. Something similar to what is seen in this visual, where we have the total lines assigned to each assigned employee ID.
 

JUANROVALETTI_0-1691356203759.png

 

 

I hope I have explained myself correctly. If not, please ask for more data or whatever is necessary to solve this problem. I would be truly grateful for your help. Regards, Juan.

2 REPLIES 2
JUANROVALETTI
Frequent Visitor

Thank you very much, it was very helpful.

Finally, after doing some research, I was able to solve it. Here is the DAX function used.

JUANROVALETTI_1-1691380631083.png

 


Now my problem arises when I want to replicate this procedure for the non-concluded requests. I created a new support table and then copied the formula in a similar way, referencing my new support table and another measure that instead of being a DATEDIFF between the release date and the order creation date, would be a DATEDIFF from the release date until today. However, I don't know why it wouldn't be working.

 

this is my new dax measures

JUANROVALETTI_2-1691380685972.pngJUANROVALETTI_3-1691380738840.png

 

 

parry2k
Super User
Super User

@JUANROVALETTI Unfortunately you cannot use the measure as a legend but you have to use this approach to handle this. Dynamic segmentation – DAX Patterns

 

👉 Learn Power BI and Fabric - subscribe to our YT channel - @PowerBIHowTo



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors