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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
JFarq
Helper I
Helper I

Simplifying slicer filter scenarios in a measure

Hi

 

I was wondering if there might be a way to simplify my measure such that I don’t need to specify every slicer filter that needs to be unselected/off for the hard-coded ‘Year count’ scenarios to occur.

 

 

Sum of SUMX CN-Q code targeted count with hard-coded Year totals final v2 = 
SWITCH( TRUE(),
    ([SelectedYear OrderAsc] = "21/22") && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[FT or PT]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Level]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Campus]) = False), "4892",
    ([SelectedYear OrderAsc] = "22/23") && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[FT or PT]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Level]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Campus]) = False), "4511",
    ([SelectedYear OrderAsc] = "23/24") && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[FT or PT]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Level]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Campus]) = False), "4853",
    ([SelectedYear OrderAsc] = "21/22, 22/23") && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[FT or PT]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Level]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Campus]) = False), "9403",
    ([SelectedYear OrderAsc] = "21/22, 23/24") && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[FT or PT]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Level]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Campus]) = False), "9745",
    ([SelectedYear OrderAsc] = "22/23, 23/24") && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[FT or PT]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Level]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Campus]) = False), "9364",
    ([SelectedYear OrderAsc] = "21/22, 22/23, 23/24") && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[FT or PT]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Level]) = False) && (ISFILTERED(Main_Inc_CC_And_tfs_SurveyResults[Campus]) = False), "14256",
    [Sum of SUMX CN-Q code targeted count]
)
SelectedYear OrderAsc = 
CONCATENATEX(
          VALUES(Main_Inc_CC_And_tfs_SurveyResults[ShortYear]),
          Main_Inc_CC_And_tfs_SurveyResults[ShortYear],
           ", ",
	  Main_Inc_CC_And_tfs_SurveyResults[ShortYear],
	  ASC
           )

 

 

 

Also so that I don’t need to update the measure scenarios everytime I add new slicers to my report page.

JFarq_0-1715679633264.png

I hope that's makes sense. Please let me know if you have any questions.

 

The source data and powerBI files are available via the following links:

AnonReportq_ns_ts_v1.pbix

AnonReportq_DataSrc_v4.xlsx

ReturnsData_21_22_to_23_24_Test_v1.xlsx

 

Any help would be really appreciated.

 

Best Wishes

JFarq

Also for your reference:

 

 

Sum of SUMX CN-Q code targeted count = 
    CALCULATE (
    [SUMX CN-Q code targeted count],
    ALLSELECTED(Main_Inc_CC_And_tfs_SurveyResults[CN-Q code])
    )
SUMX CN-Q code targeted count = SUMX( ReturnsData_21_22_to_23_24, [CN-Q code targeted count])
CN-Q code targeted count = 
    CALCULATE (
        SUM ( ReturnsData_21_22_to_23_24[Targeted] ),
        FILTER (
            ReturnsData_21_22_to_23_24,
            ReturnsData_21_22_to_23_24[CN-Q code] == MAX ( Main_Inc_CC_And_tfs_SurveyResults[CN-Q code] )
        )
    )

 

 

 

 

 

1 REPLY 1
lbendlin
Super User
Super User

Sum of SUMX CN-Q code targeted count with hard-coded Year totals final v2 =
IF(ISFILTERED ( Main_Inc_CC_And_tfs_SurveyResults[FT or PT] )
   || ISFILTERED ( Main_Inc_CC_And_tfs_SurveyResults[Level] )
   || ISFILTERED ( Main_Inc_CC_And_tfs_SurveyResults[Campus] ),[Sum of SUMX CN-Q code targeted count],
VAR y = VALUES(Main_Inc_CC_And_tfs_SurveyResults[ShortYear])
RETURN ("21/22" IN y) * 4892 +("22/23" IN y) * 4511 + ("23/24" IN y) * 4853  
)

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.

Top Kudoed Authors