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

How to stop the Switch Function from replacing a calculated value with a null value

Hello All, 

 

I could use help with the Switch ( TRUE () function. 

 

If I use a calculated value the switch result is null

Null Result.jpg

 

However, if I hardcode a number in the switch instead of the calculated field, it works fine.

Harcode Result.jpg

 

There is data in [Income] in a normal matrix column. Thank you for any help - I greatly appreciate it! 

1 ACCEPTED SOLUTION
PhilipTreacy
Super User
Super User

Hi @rmbuchan 

 

Your [PL Actuals] measure is told to return the value of [Income] when the row index is 3.  

 

[Income] calculates [PL Values] when the Category is Income.  This is the problem.  The Category for rows with row index 3 is Total Income.  That's why you're getting a blank here.

 

You can fix the issue by modifying this line in the SWITCH to 

 

 

CRSindex = 3, CALCULATE([PL Values], 'RPT Income Statement'[Category] = "Total Income"),

 

 

incs.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


View solution in original post

10 REPLIES 10
v-henryk-mstf
Community Support
Community Support

Hi @rmbuchan ,

 

Whether the advice given by @PhilipTreacy  has solved your confusion, if the problem has been solved you can mark the reply for the standard answer to help the other members find it more quickly. If not, please point it out.


Looking forward to your feedback.


Best Regards,
Henry

PhilipTreacy
Super User
Super User

Hi @rmbuchan 

 

Your [PL Actuals] measure is told to return the value of [Income] when the row index is 3.  

 

[Income] calculates [PL Values] when the Category is Income.  This is the problem.  The Category for rows with row index 3 is Total Income.  That's why you're getting a blank here.

 

You can fix the issue by modifying this line in the SWITCH to 

 

 

CRSindex = 3, CALCULATE([PL Values], 'RPT Income Statement'[Category] = "Total Income"),

 

 

incs.png

 

Regards

 

Phil

 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Phil, 

 

You are AMAZING - this solved the problem. Thank you so much for sticking with this issue and putting all the time in that you did! 

No worries @rmbuchan , glad to help.

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


PhilipTreacy
Super User
Super User

Hi @rmbuchan 

 

Can you supply your PBIX file please.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Phil, 

 

I sent you a link to the file in DropBox - thank you for your help! 

PhilipTreacy
Super User
Super User

Hi @rmbuchan 

 

It may very well produce values when charted but it's how the value is calculated when it's in the matrix that is the issue.

 

I presume [PL Values] is a measure?  How is that calculated?

 

Can you provide your file?  It woudl be easier to check if I have that.

 

Regards

 

Phil 



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Philip, 

 

Yes, PL Values is a measure. Here is the calculation: 

 

PL Values =
SUM( 'RPT Income Statement'[Act Amt])
 
The pbix file is a bit of mess right now because I've tried doing a lot of things to figure this issue out, but I can upload it if this calculation doesn't help.  
PhilipTreacy
Super User
Super User

Hi @rmbuchan 

 

How are you calculating [Income]?  That would seem to be the issue.

 

Regards

 

Phil



Did I answer your question? Then please mark my post as the solution.
If I helped you, click on the Thumbs Up to give Kudos.


Blog :: YouTube Channel :: Connect on Linkedin


Proud to be a Super User!


Philip, 

 

Great question. I thought the same thing. I put the measure into a chart and it produces results. I also have the formula shown here: 

Income Result.jpg

It just doesn't work in the Switch. Thanks for your assistance...

 

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.