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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends September 15. Request your voucher.

Reply
TaariqHussain
Helper I
Helper I

Grouping data for a visual

 

I have 2 tables items sales and a second that has item cost

both linked to master inventory table

I have a measure that calculates my GP% however i want to group my GP's as per below

TaariqHussain_0-1681976748451.png

 

thats where this formula i found on the forum comes in

Measure =
VAR __Date = MAX('ItemWiseSales'[dateinvoiced])
VAR __Category = MAX('Category'[Category])
VAR __Low =
SWITCH(
    __Category,
    "Less than 1%",-0.2,
    "1%",0.01,
    "2%",0.02,
    "3-5%",0.03,
    "5%>",0.05
)
VAR __High =
SWITCH(
    __Category,
"Less than 1%",0.01,
    "1%",0.019,
    "2%",0.029,
    "3-5%",0.049,
    "5%>",0.2
)
VAR __tmpTable = SUMMARIZE('ItemWiseSales',ItemWiseSales[itemprice],"__Percent",[GP%])
RETURN COUNTROWS(FILTER(__tmpTable,[__Percent]>=__Low && [__Percent]<=__High))
 
i than pull that measure into a pie chart but the visual is completely off
TaariqHussain_1-1681976749471.png

 

Please assist on a fix or possible alternative

original formula from a reply by @Greg_Deckler on different post

2 REPLIES 2
lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).
https://community.powerbi.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-Forum/ba-...
Please show the expected outcome based on the sample data you provided.

https://community.powerbi.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447523

Good day

 

Thank you for your response

 

As per above this a sample of a visual i want to see

pie chart.png

With that i also want to drill down each slice to see the items in that GP% range

below is my 3 sample data sources

Item sales

 

BarcodeProduct DescriptionUnit Price
FRBR8FRANGOSA BRAAI PACK 8X800G FZN36.9
3C5CHUBBY CHICK IQF 3X5KG29.75
C26CHUBBY 6X2KG IQF29.8
RHFRainbow Head And Feet 10x1kg12.5
DCD10DS - FRESH DRUMSTICK 10Kg45.5
3R5MPRB IQF MIX PORTIONS 3X5KG30.5
   

 

Last GRV Cost

Item CodeItem DescriptionLast Invoice Cost
3C5CHUBBY CHICK IQF 3X5KG28.03
3R5MPRB IQF MIX PORTIONS 3X5KG32.87
C26CHUBBY 6X2KG IQF28.03
DCD10DS - FRESH DRUMSTICK 10Kg44
FRBR8FRANGOSA BRAAI PACK 8X800G FZN28.5
RHFRainbow Head And Feet 10x1kg9.98

 

Master stock data

Item CodeItem Description
RHFRainbow Head And Feet 10x1kg
3C5CHUBBY CHICK IQF 3X5KG
C26CHUBBY 6X2KG IQF
FRBR8FRANGOSA BRAAI PACK 8X800G FZN
3R5MPRB IQF MIX PORTIONS 3X5KG
DCD10DS - FRESH DRUMSTICK 10Kg

 

Thank you

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 Kudoed Authors