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

Data Days is here! Join us now for 60+ days of learning, challenges, and connection. Learn more

Reply
holywasabi
Frequent Visitor

Using DAX in Visualisation

Hi all, I would like created a DAX measure to group users into multiple age ranges, it works well in table form.

But I get an error when using it in other types of visualizations (eg. pie charts / bar charts). 

Any pointers are greatly appreciated 😁 

 

= = = 

Here are my tables / data : 

holywasabi_0-1720346561401.png

Income (Grouped) =
VAR CustomerIncome = MAX( customer[ Income ] )

RETURN
CALCULATE(
    VALUES(  'Group : Income'[Income Range] ),

    FILTER(
    'Group : Income',
    CustomerIncome >=  'Group : Income'[Min] &&
    CustomerIncome <=  'Group : Income'[Max]
    )
)
 
= = = 
 
What I'd like to achieve : 
pie_chartpie_chart

Thank you!

 

1 ACCEPTED SOLUTION
Irwan
Super User
Super User

Hello @holywasabi 

 

please check if this accomodate your need.

Irwan_0-1720399912348.png

 

I am not sure what kind of error did you get but if it works in table form, it should work as well in other visual

Irwan_1-1720399971052.png

 

Apart from the error, please check these : 

1. Created calculated column for 'Income (Grouped)'

Income (Grouped) = MAXX(FILTER('Supporting','Income'[Income]>'Supporting'[Min]&&'Income'[Income]<'Supporting'[Max]),'Supporting'[Income Range])
Irwan_2-1720400281344.png

 

2. Since you want to create pie chart with 'Income Range' as separator/legend, then you need to make a measure to calculate it. Create measure in 'Supporting' Table with following DAX for calculating number of row that has exact same value in 'Income (Grouped)' and 'Income Range'.

Count Customer =
var _Income = SELECTEDVALUE('Supporting'[Income Range])
var _Count = COUNTX(FILTER('Income','Income'[Income (Grouped)]=_Income),COUNTROWS('Income'))
Return
IF(
    _Count=BLANK(),
    0,
    _Count
)
Irwan_5-1720400814988.png
 

3. Plot in pie chart, 'Income Range' as legend and the previous measure (Count Customer) as Values.

Irwan_3-1720400562548.png

After putting values in pie chart, in Visual Format, turn of legend and change Label Content (Detail Label -> Option).

Irwan_4-1720400735684.png

 

Also, in your screecshot table, you only provide two kind of data, the 10k-50k and 50k-100k. The rest of categories dont show up because the value is zero.

 

Hope this will help you.

Thank you.

View solution in original post

2 REPLIES 2
Irwan
Super User
Super User

Hello @holywasabi 

 

please check if this accomodate your need.

Irwan_0-1720399912348.png

 

I am not sure what kind of error did you get but if it works in table form, it should work as well in other visual

Irwan_1-1720399971052.png

 

Apart from the error, please check these : 

1. Created calculated column for 'Income (Grouped)'

Income (Grouped) = MAXX(FILTER('Supporting','Income'[Income]>'Supporting'[Min]&&'Income'[Income]<'Supporting'[Max]),'Supporting'[Income Range])
Irwan_2-1720400281344.png

 

2. Since you want to create pie chart with 'Income Range' as separator/legend, then you need to make a measure to calculate it. Create measure in 'Supporting' Table with following DAX for calculating number of row that has exact same value in 'Income (Grouped)' and 'Income Range'.

Count Customer =
var _Income = SELECTEDVALUE('Supporting'[Income Range])
var _Count = COUNTX(FILTER('Income','Income'[Income (Grouped)]=_Income),COUNTROWS('Income'))
Return
IF(
    _Count=BLANK(),
    0,
    _Count
)
Irwan_5-1720400814988.png
 

3. Plot in pie chart, 'Income Range' as legend and the previous measure (Count Customer) as Values.

Irwan_3-1720400562548.png

After putting values in pie chart, in Visual Format, turn of legend and change Label Content (Detail Label -> Option).

Irwan_4-1720400735684.png

 

Also, in your screecshot table, you only provide two kind of data, the 10k-50k and 50k-100k. The rest of categories dont show up because the value is zero.

 

Hope this will help you.

Thank you.

foodd
Community Champion
Community Champion

Hello @holywasabi , remember to adhere to the decorum of the Community Forum when asking a question.

Please provide your work-in-progress Power BI Desktop file (with sensitive information removed) that covers your issue or question completely in a usable format (not as a screenshot).

https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

This allows members of the Forum to assess the state of the model, report layer, relationships, and any DAX applied.

Helpful resources

Announcements
Fabric Data Days is here Carousel

Fabric Data Days 2026

Don't miss out on Data Days, June 15 through August 7. Learn Fabric, Power BI, SQL, AI and more.

May Power BI Update Carousel

Power BI Monthly Update - May 2026

Check out the May 2026 Power BI update to learn about new features.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.