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

Did you hear? There's a new SQL AI Developer certification (DP-800). Start preparing now and be one of the first to get certified. Register now

Reply
quickbi
Helper II
Helper II

Error SelectedValue

Hi All,

 

I'm making a P&L statement and I'm using a PL mapping section:

quickbi_0-1720689416200.png

When I create a Pivot in PBI I assign the fields as:

quickbi_1-1720689497140.png

Where selectedvaluetest show for each row what row is calculating. But I have a problem with this DAX:

 

PL Amount test = 
IF(
    SELECTEDVALUE('PL Accounts'[Level1]) = "Margin",
    CALCULATE([PL Amount Net Revenues] + [PL Amount Gross Margin]),
    SWITCH(
        TRUE(),
        SELECTEDVALUE('PL Accounts'[Level1order]) = 10, [PL Amount Net Revenues],
        SELECTEDVALUE('PL Accounts'[Level1]) = "Gross Margin", [PL Amount Gross Margin],
        SELECTEDVALUE('PL Accounts'[Level1]) = "EBITDA 4WALL", [PL Amount EBITDA 4 WALL],
        SELECTEDVALUE('PL Accounts'[Level1]) = "EBITDA", [PL Amount EBITDA],
        SELECTEDVALUE('PL Accounts'[Level1]) = "EBIT", [PL Amount EBIT],
        SELECTEDVALUE('PL Accounts'[Level1]) = "EBT", [PL Amount EBT],
        0
    )
)

Because Margin line did not appear as SelectedValuetest  value, anyone knows why?

 

quickbi_2-1720689681373.png

thanks all for your help

 

 

 

1 ACCEPTED SOLUTION

@quickbi ok, my next hypothesis is that there are some null or blank values getting in the way. Can you try changing your selectedvalue test to use

 

CONCATENATEX( VALUES(tablename[Level1]), tablename[Level1], ", " )


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

View solution in original post

3 REPLIES 3
AllisonKennedy
Community Champion
Community Champion

You may need to add some filter modifiers to your calculate and/or selectedvalue. You can see the selectedvalue test is blank for the top row for each level 1 account in your visual, and because Margin is collapsed the top row is the only one that exists. 


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Hi @AllisonKennedy 
thanks for your answer but is not the problem because all level1 are showing if they are or aren't collapsed.
...and I expanded all Margin level but did not show anyvalue

quickbi_0-1720690479393.png

 

 

@quickbi ok, my next hypothesis is that there are some null or blank values getting in the way. Can you try changing your selectedvalue test to use

 

CONCATENATEX( VALUES(tablename[Level1]), tablename[Level1], ", " )


Please @mention me in your reply if you want a response.

Copying DAX from this post? Click here for a hack to quickly replace it with your own table names

Has this post solved your problem? Please Accept as Solution so that others can find it quickly and to let the community know your problem has been solved.
If you found this post helpful, please give Kudos C

I work as a Microsoft trainer and consultant, specialising in Power BI and Power Query.
www.excelwithallison.com

Helpful resources

Announcements
April Power BI Update Carousel

Power BI Monthly Update - April 2026

Check out the April 2026 Power BI update to learn about new features.

Fabric SQL PBI Data Days

Data Days 2026 coming soon!

Sign up to receive a private message when registration opens and key events begin.

New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.