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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
BrianMac
Frequent Visitor

Help adjusting a custom measure, utilizing SWTICH, to ignore all filters and selections.

I have a custom measure, seen below, that is working quite well.  However, i would like to modify it so that it ignores any selections made.  I am using this in a custom card.  I would like it to remain representative of the total it is calculating, instead of reacting to users selections.

 

-----------------------------------------------------------------

KPIMarginLCM =
VAR _arrow =
    SWITCH(
        TRUE(),
        [Sales GP % Margin LCM] > 999999999,  "$#,##,,,.0B",  // Up Arrow when the KPI is positive
         [Sales GP % Margin LCM]> 999999, "$#,##,,.0M",
          [Sales GP % Margin LCM] > 9999,  "$#,##,K",
          [Sales GP % Margin LCM] > 9, "$#,##,",  // Down Arrow when the KPI is negative
        " "                  // Empty space when the KPI is zero
    )

VAR _metrics =  [Sales GP % Margin LCM]

RETURN
    FORMAT(_metrics, "0.0%")  // Adjust the format based on your KPI type))))Measure =

&UNICHAR(10) &

VAR _arrow =
    SWITCH(
        TRUE(),
      [Sales GP % Margin LCM YoY %] > 0, "▲",  // Up Arrow when the KPI is positive
          [Sales GP % Margin LCM YoY %] < 0, "🔻",  // Down Arrow when the KPI is negative
        " "                  // Empty space when the KPI is zero
    )

VAR _metrics = [Sales GP % Margin LCM YoY %]
RETURN
 
    _arrow & " " & FORMAT(_metrics, "0.0%")  // Adjust the format based on your KPI type))))Measure =
 
--------------------------------------------------------------------
 
thanks,
Brian
2 ACCEPTED SOLUTIONS
Kaviraj11
Super User
Super User

Got it,

 

To achieve this, you can use the ALL function to remove any filters applied by slicers. Try it out and let me know.

 

KPIMarginLCM =
VAR _arrow =
SWITCH(
TRUE(),
[Sales GP % Margin LCM] > 999999999, "$#,##,,,.0B", // Up Arrow when the KPI is positive
[Sales GP % Margin LCM] > 999999, "$#,##,,.0M",
[Sales GP % Margin LCM] > 9999, "$#,##,K",
[Sales GP % Margin LCM] > 9, "$#,##,", // Down Arrow when the KPI is negative
" " // Empty space when the KPI is zero
)

VAR _metrics = CALCULATE([Sales GP % Margin LCM], ALL())

RETURN
FORMAT(_metrics, "0.0%") // Adjust the format based on your KPI type

& UNICHAR(10) &

VAR _arrow2 =
SWITCH(
TRUE(),
[Sales GP % Margin LCM YoY %] > 0, "▲", // Up Arrow when the KPI is positive
[Sales GP % Margin LCM YoY %] < 0, "▼", // Down Arrow when the KPI is negative
" " // Empty space when the KPI is zero
)

VAR _metrics2 = CALCULATE([Sales GP % Margin LCM YoY %], ALL())
RETURN
_arrow2 & " " & FORMAT(_metrics2, "0.0%") // Adjust the format based on your KPI type




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

Proud to be a Super User!





View solution in original post

4 REPLIES 4
Kaviraj11
Super User
Super User

Got it,

 

To achieve this, you can use the ALL function to remove any filters applied by slicers. Try it out and let me know.

 

KPIMarginLCM =
VAR _arrow =
SWITCH(
TRUE(),
[Sales GP % Margin LCM] > 999999999, "$#,##,,,.0B", // Up Arrow when the KPI is positive
[Sales GP % Margin LCM] > 999999, "$#,##,,.0M",
[Sales GP % Margin LCM] > 9999, "$#,##,K",
[Sales GP % Margin LCM] > 9, "$#,##,", // Down Arrow when the KPI is negative
" " // Empty space when the KPI is zero
)

VAR _metrics = CALCULATE([Sales GP % Margin LCM], ALL())

RETURN
FORMAT(_metrics, "0.0%") // Adjust the format based on your KPI type

& UNICHAR(10) &

VAR _arrow2 =
SWITCH(
TRUE(),
[Sales GP % Margin LCM YoY %] > 0, "▲", // Up Arrow when the KPI is positive
[Sales GP % Margin LCM YoY %] < 0, "▼", // Down Arrow when the KPI is negative
" " // Empty space when the KPI is zero
)

VAR _metrics2 = CALCULATE([Sales GP % Margin LCM YoY %], ALL())
RETURN
_arrow2 & " " & FORMAT(_metrics2, "0.0%") // Adjust the format based on your KPI type




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

Proud to be a Super User!





Thank you!

 

Kaviraj11
Super User
Super User

Hi, 

 

You can do this without modifying your measure:

 

First, you need to select the slicer and make sure you are under Format Tab. Select Edit Interactions and then disable the visual you don't want an impact on.

 

Change how visuals interact in a report - Power BI | Microsoft Learn

Kaviraj11_1-1725989954089.png

 

 




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

Proud to be a Super User!





I was aware of that as well, but if a user utilizes hidden filters it will impact it.  also i have a handfull of different custom measure i want to apply the logic too.

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount! Prices go up Feb. 11th.

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

Jan NL Carousel

Fabric Community Update - January 2025

Find out what's new and trending in the Fabric community.