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

Find everything you need to get certified on Fabric—skills challenges, live sessions, exam prep, role guidance, and more. Get started

Reply
eshwarramesh97
Frequent Visitor

Switch Function not giving expected result

Hello Forum,

I want to create a calculated column which uses a value from another column and result is based upon that but it is giving me blank Dax for calculated column as below

Column = switch('Table'[Column1],"a",CALCULATE(sum('Table'[Column2]),'Table'[Column1]="f",'Table'[Column3]=2020))
Data set as follows
eshwarramesh97_0-1647608745708.png

Could you please help me to find out the solution @amitchandak  @AlexisOlson @Greg_Deckler 

Thanks in advance

 

1 ACCEPTED SOLUTION
v-angzheng-msft
Community Support
Community Support

Hi, @eshwarramesh97 

 

Try this:

Column = 
SWITCH (
    'Table'[Column1],
    "a",
        CALCULATE (
            SUM ( 'Table'[Column2] ),
            ALL('Table'),
            'Table'[Column1] = "f",
            'Table'[Column3] = 2020
        )
)

Result:

vangzhengmsft_0-1648187745555.png

Please refer to the attachment below for details.

Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

View solution in original post

3 REPLIES 3
v-angzheng-msft
Community Support
Community Support

Hi, @eshwarramesh97 

 

Try this:

Column = 
SWITCH (
    'Table'[Column1],
    "a",
        CALCULATE (
            SUM ( 'Table'[Column2] ),
            ALL('Table'),
            'Table'[Column1] = "f",
            'Table'[Column3] = 2020
        )
)

Result:

vangzhengmsft_0-1648187745555.png

Please refer to the attachment below for details.

Hope this helps.

 

 

Best Regards,
Community Support Team _ Zeon Zheng


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

eshwarramesh97
Frequent Visitor

Hello @goncalogeraldes  thanks for your reply tried with your solution but still gives same blank

goncalogeraldes
Super User
Super User

Hello there @eshwarramesh97 ! Check if this solves your problem:

Column =
SWITCH (
    SELECTEDVALUE ( 'Table'[Column1] ),
    "a",
        CALCULATE (
            SUM ( 'Table'[Column2] ),
            'Table'[Column1] = "f",
            'Table'[Column3] = 2020
        )
)

Hope this answer solves your problem!
If you need any additional help please @ me in your reply.
If my reply provided you with a solution, please consider marking it as a solution ✔️ or giving it a kudoe 👍
Thanks!

You can also check out my LinkedIn!

Best regards,
Gonçalo Geraldes

Helpful resources

Announcements
Fabcon_Europe_Social_Bogo

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

Power BI Carousel June 2024

Power BI Monthly Update - June 2024

Check out the June 2024 Power BI update to learn about new features.

PBI_Carousel_NL_June

Fabric Community Update - June 2024

Get the latest Fabric updates from Build 2024, key Skills Challenge voucher deadlines, top blogs, forum posts, and product ideas.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.