Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!
Hello everyone,
I'm struggling to solve a problem with a measure.
I am using Switch + Selectedvalue to build a customized P&L report in Power BI, but two of lines "Other COGS" and "Ratio 1 return blank.
Here is my data model and formula. Could anyone help me check? Thank you in advance!
Solved! Go to Solution.
If you are performing a division, you are going to need to remove the row filters. Something along the lines of:
Ratio =
VAR _Profit =
CALCULATE ( [Gross Profit], ALL ( 'P&L Structure' ))
VAR _NetSales =
CALCULATE ( [Net Sales], ALL ( 'P&L Structure' ))
RETURN
DIVIDE ( _Profit, _NetSales )
Proud to be a Super User!
Paul on Linkedin.
@Wangfl Remember that SELECTEDVALUE will return blank by default if it finds two or more different values in the rows it is analyzing.
hi Greg,
Thank you for fast response. however, the measure [Other COGS] and [Ratio 1]that I refer to seems is only one value. But if I change formula into constant number. it will shows up! Could you help me understand what is going on? 😭
@Wangfl Well, not sure all of the information is present to make a determination of what is going on. Also, I misread this initially. So, what are the formulas for your Ratio 1 and Other COGs measures? It is possible that in the context of the table visual that either the relationship is not matching those up or the context is changed such that the measures don't work as expected. If the measures are referencing the EPM table then pick a column in that table and do a count to get a row count in the table visual you are using. If the row count for those two come back zero or blank, then something is not matching up.
If you are performing a division, you are going to need to remove the row filters. Something along the lines of:
Ratio =
VAR _Profit =
CALCULATE ( [Gross Profit], ALL ( 'P&L Structure' ))
VAR _NetSales =
CALCULATE ( [Net Sales], ALL ( 'P&L Structure' ))
RETURN
DIVIDE ( _Profit, _NetSales )
Proud to be a Super User!
Paul on Linkedin.
Hii,
Thank you so much!! Its working now.
Could help me do the last favor? 🙂
Is a way to make this formula more short and clean?
It looks pretty succinct to me....Not sure you can do much more there...
Proud to be a Super User!
Paul on Linkedin.
Lol.. Got it!
Thank you again~😀
It may be because there is a rogue blank in the field value. Try performing a "Trim" (and maybe "Clean") on the column in Power Query.
or even simpler, instead of referencig the name (value) in SELECTEDVALUE, use the Line Item Number instead
Proud to be a Super User!
Paul on Linkedin.
Hi Thank you for fast response.
however, it seems like the column quality is all good..
Just for future reference, I actually meant (though my wording was indeed confusing) that one of the actual values may contain a blank at the end of the word/string - not a blank as an actual value. If you perform a Trim on the column, it cleans up any blank (character) at the end of a string
Proud to be a Super User!
Paul on Linkedin.
The Power BI Data Visualization World Championships is back! It's time to submit your entry.
Check out the January 2026 Power BI update to learn about new features.
| User | Count |
|---|---|
| 69 | |
| 45 | |
| 36 | |
| 28 | |
| 23 |
| User | Count |
|---|---|
| 141 | |
| 124 | |
| 59 | |
| 40 | |
| 32 |