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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

SWITCH(TRUE() Divide Function returning error : "Switch Function does not support comparing values"

Hi Guys,

I have  a custom table created using the Switch true function. After adding a divide expression to my 3rd switch function 

it returns an error. Does anyone know why?

adrianchy_0-1641865232287.png
Thank you

 

1 ACCEPTED SOLUTION
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Try this measure,

Planned Metric =
VAR _a =
    SELECTEDVALUE ( 'Planned Accounts Table'[Description] )
RETURN
    IF (
        _a = "FY22Q4 Total Planned Accounts CAP",
        FORMAT ( [Count of Accounts], "0,00" ),
        IF (
            _a = "Quote Tap",
            [AP_Automation_CountofQuotes],
            IF ( _a = "Quote Tap Rate %", [Quote Tap Rate] )
        )
    )

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

7 REPLIES 7
v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Have you solved this question? If you have solved the question, you can accept the answer helpful as the solution or share you method and accept it as solution, thanks for your contribution to improve Power BI.❤️

If you need more help, please let me know.

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

v-xiaotang
Community Support
Community Support

Hi @Anonymous 

Try this measure,

Planned Metric =
VAR _a =
    SELECTEDVALUE ( 'Planned Accounts Table'[Description] )
RETURN
    IF (
        _a = "FY22Q4 Total Planned Accounts CAP",
        FORMAT ( [Count of Accounts], "0,00" ),
        IF (
            _a = "Quote Tap",
            [AP_Automation_CountofQuotes],
            IF ( _a = "Quote Tap Rate %", [Quote Tap Rate] )
        )
    )

 

Best Regards,

Community Support Team _Tang

If this post helps, please consider Accept it as the solution to help the other members find it more quickly.

VahidDM
Super User
Super User

HI @Anonymous 

 

You don't need to write the Switch and True for each line.

 

https://docs.microsoft.com/en-us/dax/switch-function-dax

 

Can you copy and paste your formula here, then I will correct that.

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Anonymous
Not applicable

 

Planned Metric = 

SWITCH(TRUE(),SELECTEDVALUE('Planned Accounts Table'[Description])="FY22Q4 Total Planned Accounts CAP",FORMAT([Count of Accounts],"0,00"), 
SWITCH(TRUE(),SELECTEDVALUE('Planned Accounts Table'[Description])="Quote Tap",[AP_Automation_CountofQuotes]))
//SWITCH(TRUE(),SELECTEDVALUE('Planned Accounts Table'[Description])="Quote Tap Rate %",[Quote Tap Rate]))

here you go

 

@Anonymous 

 

Try this:

Planned Metric =
SWITCH (
    TRUE (),
    SELECTEDVALUE ( 'Planned Accounts Table'[Description] ) = "FY22Q4 Total Planned Accounts CAP", FORMAT ( [Count of Accounts], "0,00" ),
    SELECTEDVALUE ( 'Planned Accounts Table'[Description] ) = "Quote Tap", [AP_Automation_CountofQuotes]
)
    / SWITCH (
        TRUE (),
        SELECTEDVALUE ( 'Planned Accounts Table'[Description] ) = "Quote Tap Rate %", [Quote Tap Rate]
    )

 

But it seems there is an issue with the logic of your formula, all of those conditions are based on the selectedvalue on a same column!!

 

if that does not work, please share a sample of your data and the expected result, maybe there is another way to find the solution.

 

 

If this post helps, please consider accepting it as the solution to help the other members find it more quickly.
Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Anonymous
Not applicable

Hi Vahid

Im getting this error. I'm very sure all the formatting is changed to whole number format . However, the error is still showing. Is this because the first two switch functions are numerical wheareas the last switch function is in %.

adrianchy_0-1641870384767.png

 

@Anonymous 

please share a sample of your data and the expected result in a text format

 


Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors