Forum Discussion

Ferha_Jafri's avatar
Ferha_Jafri
Frequent Visitor
1 year ago
Solved

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 ...
  • tharunkumarRTK's avatar
    1 year ago

    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!