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

Get certified in Microsoft Fabric—for free! For a limited time, get a free DP-600 exam voucher to use by the end of 2024. Register now

Reply
willit6182
Frequent Visitor

Creating Visual Categories based on Calculated Measure

I would love some help from you all re making legend categories for a visual from a calculated measure.

 

Below is representative data that I have in a single table:

EncounterCodeRVUMonth
1                      49083        2              Jan
2360143.02Jan
2360153.51Jan
2372110Jan
2769370.3Jan
3494522.86Feb
4101601.25Feb
4770121.5Feb
5475347.6March
6939220.25March
7365892.28March
7369013.36March
8490832March
9100051.46March
10382221.44March
10770121.5March

 

As you can see, multiple Billing Codes and associated RVU Values for each Encounter. I am trying to make a stacked column chart visual:

Y- axis = Count of Encounter (Distinct)

X- axis = grouped by Month

Legend = "Sum RVU for Encounter > 5" OR "Sum RVU for Encounter < 5"

         (i.e. Encounter 1 = 2.0 RVU; Encounter 2 = 6.83 RVU; etc)

 

I have correctly classified individual Encounters as ">5" (High) or "<5" (Low) in a table visual as below using the following measure...

 

willit6182_0-1720736733554.png

 

Total RVU Classification :=
VAR TotalRVU = SUMX(
VALUES('Table'[Encounter]),
CALCULATE(
SUM('Table'[RVU])
)
)
RETURN
IF(TotalRVU > 5, "High", "Low")

HOWEVER, I am not able to drag this measure to the legend field in my bar chart as I thought I could so that I can get stacked columns delineated by the 2 categories. Can anyone shed light on this? Do I need to be using a different measure or data format to allow it to be put into the legend field?
 
Thanks!!
2 ACCEPTED SOLUTIONS
Irwan
Memorable Member
Memorable Member

hello @willit6182 

 

I believe you can only add column as visual legend.

So if you have to add legend, you need to make another calculated column which defines Total RVU Classification.

 

Here is one of many ways to do this.

1. create new table and summarize your original table. In summarize table, calculate sum of RVU as well.

Summarize =
SUMMARIZE(
    'Table',
    'Table'[Encounter],
    'Table'[Month],
    "Sum RVU per Encounter",
    CALCULATE(SUM('Table'[RVU]),FILTER(ALL('Table'),'Table'[Encounter]=EARLIER('Table'[Encounter])))
)

Irwan_0-1720747866261.png

 

2. create a calculated column to define Total RVU Classification.

Total RVU Classification =
IF(
    'Summarize'[Sum RVU per Encounter]>5,
    "High",
    "Low"
)

Irwan_1-1720747924271.png

 

3. make relationship between original table and summarized table.

Irwan_2-1720747983544.png

 

4. plot your data in stacked column chart. Take Total RVU Classification column as visual legend.

Irwan_3-1720748039811.png

Also dont forget to change Y-Axis value into count distinct since you want to show encounter value as distinct value.

Irwan_4-1720748124968.png

 

Now, let us check using your original table. i.e in March, the red color indicates sum of RVU that will get High in Total RVU Classification. While the green color indicates sum of RVU that will get Low in Total RVU Classification.

Irwan_8-1720748562222.png

and in stacked visual in March, value of High is 2 (distinct count encounter red color) and value of Low is 4 (distinct count encounter green color).

Irwan_7-1720748495917.png

 

 

Hope this will help you.

Thank you.

 

View solution in original post

v-kaiyue-msft
Community Support
Community Support

Hi @willit6182 ,

 

Thanks for the reply from @Irwan , please allow me to provide another insight:

 

In Power BI, a Measure is usually not used directly as a legend field. Legend fields usually require a Dimension, which is categorical data, whereas Measures are numeric data that are used for calculations and aggregation.

 

You can put it into the legend by creating calculated columns.

Total RVU Classification =
VAR TotalRVU =
    CALCULATE (
        SUM ( 'Table'[RVU] ),
        FILTER ( 'Table', 'Table'[Encounter] = EARLIER ( 'Table'[Encounter] ) )
    )
RETURN
    IF ( TotalRVU > 5, "High", "Low" )

 

vkaiyuemsft_0-1720749636271.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

2 REPLIES 2
v-kaiyue-msft
Community Support
Community Support

Hi @willit6182 ,

 

Thanks for the reply from @Irwan , please allow me to provide another insight:

 

In Power BI, a Measure is usually not used directly as a legend field. Legend fields usually require a Dimension, which is categorical data, whereas Measures are numeric data that are used for calculations and aggregation.

 

You can put it into the legend by creating calculated columns.

Total RVU Classification =
VAR TotalRVU =
    CALCULATE (
        SUM ( 'Table'[RVU] ),
        FILTER ( 'Table', 'Table'[Encounter] = EARLIER ( 'Table'[Encounter] ) )
    )
RETURN
    IF ( TotalRVU > 5, "High", "Low" )

 

vkaiyuemsft_0-1720749636271.png

If your Current Period does not refer to this, please clarify in a follow-up reply.

 

Best Regards,

Clara Gong

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Irwan
Memorable Member
Memorable Member

hello @willit6182 

 

I believe you can only add column as visual legend.

So if you have to add legend, you need to make another calculated column which defines Total RVU Classification.

 

Here is one of many ways to do this.

1. create new table and summarize your original table. In summarize table, calculate sum of RVU as well.

Summarize =
SUMMARIZE(
    'Table',
    'Table'[Encounter],
    'Table'[Month],
    "Sum RVU per Encounter",
    CALCULATE(SUM('Table'[RVU]),FILTER(ALL('Table'),'Table'[Encounter]=EARLIER('Table'[Encounter])))
)

Irwan_0-1720747866261.png

 

2. create a calculated column to define Total RVU Classification.

Total RVU Classification =
IF(
    'Summarize'[Sum RVU per Encounter]>5,
    "High",
    "Low"
)

Irwan_1-1720747924271.png

 

3. make relationship between original table and summarized table.

Irwan_2-1720747983544.png

 

4. plot your data in stacked column chart. Take Total RVU Classification column as visual legend.

Irwan_3-1720748039811.png

Also dont forget to change Y-Axis value into count distinct since you want to show encounter value as distinct value.

Irwan_4-1720748124968.png

 

Now, let us check using your original table. i.e in March, the red color indicates sum of RVU that will get High in Total RVU Classification. While the green color indicates sum of RVU that will get Low in Total RVU Classification.

Irwan_8-1720748562222.png

and in stacked visual in March, value of High is 2 (distinct count encounter red color) and value of Low is 4 (distinct count encounter green color).

Irwan_7-1720748495917.png

 

 

Hope this will help you.

Thank you.

 

Helpful resources

Announcements
November Carousel

Fabric Community Update - November 2024

Find out what's new and trending in the Fabric Community.

Live Sessions with Fabric DB

Be one of the first to start using Fabric Databases

Starting December 3, join live sessions with database experts and the Fabric product team to learn just how easy it is to get started.

Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Early Bird pricing ends December 9th.

Nov PBI Update Carousel

Power BI Monthly Update - November 2024

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