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
Ferha_Jafri
Frequent Visitor

DAX expression working for table but not for bar bar chart

Hello Experts,

 

I am facing an issue in power bi as I have created an inline table as 

View = {"No. of Claims","Total Premium","Total Incurred"}
on the basis of above I wrote an expression as 
Prem_Cla_Inc toggle =
 var selected_toggle = SELECTEDVALUE(View[Value])
 var var_value = SWITCH(TRUE(),
selected_toggle = "Total Premium",FORMAT([Sum_Premium],"$#,##0.00"),
selected_toggle = "Total Incurred",FORMAT([Sum_Incured],"$#,##0.00"),
selected_toggle = "No. of Claims",FORMAT([# Claims],"#,##0"),0
)
 RETURN var_value
 
the issue as when I am creating a table woth dimention from the main table the data gets populated as
Ferha_Jafri_0-1726322852459.png

although the chart is not working as below

Ferha_Jafri_1-1726322927440.png

Not able to understand the issue.

1 ACCEPTED SOLUTION
tharunkumarRTK
Super User
Super User

@Ferha_Jafri 

 

If you use FORMAT function then your measure output would be a text value but not a numeric value. For your usecase you need to use dynamic format strings. 

https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-dynamic-format-strings

 

Your measure expression can be :

Prem_Cla_Inc toggle =
 var selected_toggle = SELECTEDVALUE(View[Value])
 var var_value = 
SWITCH(
      TRUE(),
      selected_toggle = "Total  Premium", CALCULATE([Sum_Premium],ALLEXCEPT(Final_Table,Final_Table[Loss_Band])),
      selected_toggle = "Total Incurred", [Sum_Incured],
      selected_toggle = "No. of Claims", [# Claims],
      0
            )
 RETURN var_value

 

Dynamic format string can be :

var selected_toggle = SELECTEDVALUE(View[Value])
var var_value = SWITCH(TRUE(),
selected_toggle = "Total Premium","$#,##0.00" ,
selected_toggle = "Total Incurred", "$#,##0.00" ,
selected_toggle = "No. of Claims", "#,##0" 
,0
)
 RETURN var_value

 

Need a Power BI Consultation? Hire me on Upwork

 

 

 

Connect on LinkedIn

 

 

 








Did I answer your question? Mark my post as a solution!
If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!


PBI_SuperUser_Rank@2x.png

 

View solution in original post

1 REPLY 1
tharunkumarRTK
Super User
Super User

@Ferha_Jafri 

 

If you use FORMAT function then your measure output would be a text value but not a numeric value. For your usecase you need to use dynamic format strings. 

https://learn.microsoft.com/en-us/power-bi/create-reports/desktop-dynamic-format-strings

 

Your measure expression can be :

Prem_Cla_Inc toggle =
 var selected_toggle = SELECTEDVALUE(View[Value])
 var var_value = 
SWITCH(
      TRUE(),
      selected_toggle = "Total  Premium", CALCULATE([Sum_Premium],ALLEXCEPT(Final_Table,Final_Table[Loss_Band])),
      selected_toggle = "Total Incurred", [Sum_Incured],
      selected_toggle = "No. of Claims", [# Claims],
      0
            )
 RETURN var_value

 

Dynamic format string can be :

var selected_toggle = SELECTEDVALUE(View[Value])
var var_value = SWITCH(TRUE(),
selected_toggle = "Total Premium","$#,##0.00" ,
selected_toggle = "Total Incurred", "$#,##0.00" ,
selected_toggle = "No. of Claims", "#,##0" 
,0
)
 RETURN var_value

 

Need a Power BI Consultation? Hire me on Upwork

 

 

 

Connect on LinkedIn

 

 

 








Did I answer your question? Mark my post as a solution!
If I helped you, click on the Thumbs Up to give Kudos.

Proud to be a Super User!


PBI_SuperUser_Rank@2x.png

 

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.