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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
trespass
Frequent Visitor

Pie chart on a calculated measure in DirectQuery mode

Hi All,

 

I'm trying to create a Pie chart using a calculated measure in DirectQuery mode (so, I'm not able to create a new  "Table" as suggested in previous post).

 

here my data:

 

STORE |  STORE VALUE  |   STORECLASS 

A                    100                       H

B                      90                       L 

C                    120                       H

 

"STOREVALUE" is a measure calculated as 'SUM(Table[money])'

"STORECLASS" is a measure calculated as 'IF(Table[STOREVALUE] >= 100 ,"H","L")'

 

I can't use STORECLASS as Legend and its count as Value (cannot use measure as legend), and I'm not able to find any alternatives than usi R code and embed it in ggplot2.

 

Is there a way to build a pie chart using calculated classes and their count?

 

 many thnaks and best regards,

 

Massimo

1 ACCEPTED SOLUTION

Hi @trespass

Ok, got it. You can use Group by in Power Query Editor, SUM('Table'[money]) group by 'Table'[STORE], click Apply. Then in Power BI desktop interface, you can create a calculated column STORECLASS. Finally, you will create a pie chart as described above.

Best Regards,
Angelia

View solution in original post

3 REPLIES 3
v-huizhn-msft
Microsoft Employee
Microsoft Employee

Hi @trespass,

You want tp display H(count:2) and L(count:1) in the pie chart, right? If my understanding is right, we can't bulid a pie chart using calculated classes(measure) and their count.

But there is an option, you can create a new table and create calculated column, add the column as legend.

1. Create a new table by clicking "New Table" under Modeling on Home page using the formula.

NewTable = SUMMARIZE('Table','Table'[STORE],"STOREVALUE",SUM('Table'[money]))

1.PNG

2. Then create a calculated column using the formula.

STORECLASS = IF(NewTable[STOREVALUE]>=100,"H","L")

2.PNG

3. Create a pie chart, select STORECLASS as Legend, and count of STORECLASS as value, you will get expected result as follows.

3.png

Best Regards,
Angelia

Hi Angelia,

 

thanks a lot for you support, but in Direct Query mode the "Table" button is disabled. I can't crate new tables using your code.

 

best regards,

 

Massimo

 

Hi @trespass

Ok, got it. You can use Group by in Power Query Editor, SUM('Table'[money]) group by 'Table'[STORE], click Apply. Then in Power BI desktop interface, you can create a calculated column STORECLASS. Finally, you will create a pie chart as described above.

Best Regards,
Angelia

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors