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 August 31st. Request your voucher.

Reply
Anonymous
Not applicable

DAX function to return numeric or percent values depending on metric used

Hi All,

 

I need to visualize certain metrics on a single line chart and the y axis needs to switch between numeric and percent based values on a selected metric.

 

The DAX I've written is shown below. When selecting different metrics, the values only show numeric whole numbers for values where I need it to be a percentage. Any help would be much appreciated, personally I think I am using the wrong DAX function after the RETURN bit but not sure what DAX function to use. 

 

DAX written:

 

 

Retention Trend Charts Measure =
VAR _selectedTrend = [_Selected Trend ID (Retention)]
VAR _data =
SWITCH(TRUE(),
-- Fixed Term
_selectedTrend =1,[Customers Up for Renewal],
_selectedTrend =2,[Customers Retained],
_selectedTrend =3,[Customer Retention Rate]*100,
_selectedTrend =4,ROUND([SqM Up for Renewal],0),
_selectedTrend =5,ROUND([SqM Retained],0),
_selectedTrend =6,[Customer Retention Rate]*100,
_selectedTrend =7,CALCULATE([Monthly Revenue Lost (Renewal Terminations)], 'product'[Product Group] = "Office"), --office
_selectedTrend =8,CALCULATE([Monthly Revenue Lost (Renewal Terminations)], 'product'[Product Group] = "Virtual Office"), -- v.office
_selectedTrend =9,[Monthly Revenue Lost % (Renewal Terminations)],
_selectedTrend =10,[Deals Discounted % (Renewal)]*100,
_selectedTrend =11,[Discount Depth (Renewal)],
_selectedTrend =12,[Price Increase Achived (L3M) % (Renewal)]*100,
-- office
_selectedTrend =13,ROUND([MtM Active Contracts],0),
_selectedTrend =14,ROUND([MtM Terminated Contracts],0),
_selectedTrend =15,[Churn Rate % MTM (Renewals)]*100 ,
_selectedTrend =16,ROUND([Active MtM Contracts Average Tenure],1),
_selectedTrend =17,ROUND([Terminated MtM Contracts Average Tenure],1),
-- v.office
_selectedTrend =18,ROUND([MtM Active Contracts],0),
_selectedTrend =19,ROUND([MtM Terminated Contracts],0),
_selectedTrend =20,[Churn Rate % MTM (Renewals)]*100,
_selectedTrend =21,ROUND([Active MtM Contracts Average Tenure],1),
_selectedTrend =22,ROUND([Terminated MtM Contracts Average Tenure],1)
)

RETURN

SWITCH( TRUE(),
 
_selectedTrend =1,ROUND((_data),0),
_selectedTrend =2,ROUND((_data),0),
_selectedTrend =3,ROUND((_data * 100),1),
_selectedTrend =4,ROUND((_data),0),
_selectedTrend =5,ROUND((_data),0),
_selectedTrend =6,ROUND((_data * 100),1),
_selectedTrend =7,ROUND(_data,0),
_selectedTrend =8,ROUND(_data,0),
_selectedTrend =9,ROUND((_data * 100),1),
_selectedTrend =10,ROUND((_data * 100),1),
_selectedTrend =11,ROUND(_data,0),
_selectedTrend =12,ROUND((_data * 100),1),
_selectedTrend =13,ROUND(_data,0),
_selectedTrend =14,ROUND(_data,0),
_selectedTrend =15,ROUND((_data * 100),1),
_selectedTrend =16,ROUND(_data,0),
_selectedTrend =17,ROUND(_data,0),
_selectedTrend =18,ROUND(_data,0),
_selectedTrend =19,ROUND(_data,0),
_selectedTrend =20,ROUND((_data * 100),1),
_selectedTrend =21,ROUND(_data,0),
_selectedTrend =22,ROUND(_data,0),

_data)
 
Photo below should be showing percentage values;
willpereira108_0-1620298411741.png

 

 
Your help would be most appreciated on this matter!
 
 
2 REPLIES 2
Anonymous
Not applicable

If you want to dynamically format measures, you have to use calculation groups.

Anonymous
Not applicable

@Anonymous Thank you for this, I am trying to use calculation groups in Tabular editor however, the following measures I am trying to input into the calculation group do not work when used in the line chart, what is wrong with the following x5 DAX expressions? 

 

willpereira108_6-1620326856583.png

 

willpereira108_7-1620326872279.pngwillpereira108_8-1620326884456.pngwillpereira108_9-1620326898338.pngwillpereira108_10-1620326920503.png

 

Helpful resources

Announcements
July PBI25 Carousel

Power BI Monthly Update - July 2025

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

Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 community update carousel

Fabric Community Update - June 2025

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