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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
lfholland
Advocate I
Advocate I

Alternative to SWITCH ()?

My row level security access table has a one to many relationship with my fact table.  In this particular chart, when I filter on one of the roles, it filters the data associated with the measures correctly, but leaves the all the dimension items regardless of relation.  Filtering works correctly on all other charts/graphs in the report except for this one.  I think it is associated with the fact that the two metrics are calculated using the SWITCH () function - that's the only difference I can see.  Any ideas on a possible solution?

Formula for Net Sales

Net Sales = SWITCH(TRUE(),
MAX('Period Column Table'[Period]) = "This Month", FORMAT('Summary table Calculations'[Net Sales This Month],"$#,##0;($#,##0)"),
MAX('Period Column Table'[Period]) = "TM - 1", FORMAT('Summary table Calculations'[Net Sales TM - 1],"$#,##0;($#,##0)"),
MAX('Period Column Table'[Period]) = "TM - 2", FORMAT('Summary table Calculations'[Net Sales TM - 2],"$#,##0;($#,##0)"),
MAX('Period Column Table'[Period]) = "TM - 3", FORMAT('Summary table Calculations'[Net Sales TM - 3],"$#,##0;($#,##0)"),
MAX('Period Column Table'[Period]) = "TM - 4", FORMAT('Summary table Calculations'[Net Sales TM - 4],"$#,##0;($#,##0)"),
MAX('Period Column Table'[Period]) = "TM - 5", FORMAT('Summary table Calculations'[Net Sales TM - 5],"$#,##0;($#,##0)"),
MAX('Period Column Table'[Period]) = "CY YTD", FORMAT([TY YTD Net Sales],"$#,##0;($#,##0)"),
MAX('Period Column Table'[Period]) = "PY YTD", FORMAT([LY YTD Net Sales],"$#,##0;($#,##0)"),
MAX('Period Column Table'[Period]) = "YTD Var", FORMAT(MyMeasures[YOY Growth],"Percent")
)
 
Image of dashboard when a filter is applied:
 
lfholland_0-1752691300963.png

 

1 ACCEPTED SOLUTION
lfholland
Advocate I
Advocate I

I ended up brining the role into the fact table since it was a one (access) to many (fact).  It works that way but I would think there's a better way.  And it is definately the SWITCH function.  I tried the table with other elements and it worked fine until I added the metric using SWITCH.

View solution in original post

7 REPLIES 7
Aburar_123
Solution Supplier
Solution Supplier

Hi @lfholland ,

Please unselect "Show items with no data" option and check,

Aburar_123_0-1753155864807.png

 

Unfortunately this is already deselected.

v-pgoloju
Community Support
Community Support

Hi @lfholland,

 

Thank you for reaching out to the Microsoft Fabric Forum Community, and special thanks to @danextian  and @Greg_Deckler  for prompt and helpful responses.

 

Just following up to see if the responses provided by community members were helpful in addressing the issue.

If one of the responses helped resolve your query, please consider marking it as the Accepted Solution. Feel free to reach out if you need any further clarification or assistance.

 

Best regards,
Prasanna Kumar

danextian
Super User
Super User

Hi @lfholland 

Possibly due to the use of FORMAT.  This function returns a text and still applies formatting to a blank value but of course returns a white space. Try using dynamic format strings instead.

danextian_0-1752724238421.png

 

IF (
    MAX ( 'Period Column Table'[Period] ) = "YTD Var",
    "Percent",
    "$#,##0;($#,##0)"
)

 





Dane Belarmino | Microsoft MVP | Proud to be a Super User!

Did I answer your question? Mark my post as a solution!


"Tell me and I’ll forget; show me and I may remember; involve me and I’ll understand."
Need Power BI consultation, get in touch with me on LinkedIn or hire me on UpWork.
Learn with me on YouTube @DAXJutsu or follow my page on Facebook @DAXJutsuPBI.
lfholland
Advocate I
Advocate I

I ended up brining the role into the fact table since it was a one (access) to many (fact).  It works that way but I would think there's a better way.  And it is definately the SWITCH function.  I tried the table with other elements and it worked fine until I added the metric using SWITCH.

Greg_Deckler
Community Champion
Community Champion

@lfholland Have you checked this box on the relationship?

Greg_Deckler_0-1752694375644.png

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

I did and that didn't resolve it.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.