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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
wokka
Helper IV
Helper IV

How to add slicer value to existing measure

I have a custom measure that produces a certain numeric value.

 

I have a slicer on the page for a range of values, say -20 to +10 for days that comes from a table & column

of a dimension table  'Days'[Days until sold]

What I want to do is remove the slicer from the page completely ( including removing other visual filters ) and include the code for it into my measure.

 

_TheValue =

VAR ThisMonthValue = [Lines referred]

VAR   GrandTotal =
      CALCULATE('mytable'[MyColumn] )

 VAR   Endresult =  Grandtotal * 0.25
 
RETURN
     Endresult

 

I had another DAX calculation I did that looks like this, but am unsure about how to incorprorate it into rhe existing code above

 

_NumberofValues

           = CALCULATE(distinctcountnoblank('Mytable'[column]),

                         FILTER('Mytable',RELATED('Calendar'[month]) = 1))

 

Any help appreciated

 

1 ACCEPTED SOLUTION
burakkaragoz
Community Champion
Community Champion

Hi @wokka ,

 

If you want to remove the slicer from the page and instead embed its logic directly into your measure, you can do that by adding a FILTER condition inside your CALCULATE.

Assuming your slicer was filtering 'Days'[Days until sold] between -20 and +10, you can rewrite your measure like this:

_TheValue =
VAR ThisMonthValue = [Lines referred]
VAR GrandTotal =
    CALCULATE(
        SUM('Mytable'[MyColumn]),
        FILTER(
            'Days',
            'Days'[Days until sold] >= -20 &&
            'Days'[Days until sold] <= 10
        )
    )
VAR Endresult = GrandTotal * 0.25
RETURN
    Endresult

This way, the filter is baked into the measure and you can safely remove the slicer from the report page.

If you also want to include something like your _NumberofValues logic, you can nest another CALCULATE or add it as a separate variable depending on how you want to use it in the final result.

Let me know if you want help combining both into one measure.

If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
translation and formatting supported by AI

View solution in original post

2 REPLIES 2
wokka
Helper IV
Helper IV

Thanks, thats great

 

Takin it a step further, if I wanted to include an additional second filter for a different table in the same code, how do you include that please in your code above? That way I can remove all slicers and filters from the page and create very specific filters based on many different coded-in filters.

 

Thank you

burakkaragoz
Community Champion
Community Champion

Hi @wokka ,

 

If you want to remove the slicer from the page and instead embed its logic directly into your measure, you can do that by adding a FILTER condition inside your CALCULATE.

Assuming your slicer was filtering 'Days'[Days until sold] between -20 and +10, you can rewrite your measure like this:

_TheValue =
VAR ThisMonthValue = [Lines referred]
VAR GrandTotal =
    CALCULATE(
        SUM('Mytable'[MyColumn]),
        FILTER(
            'Days',
            'Days'[Days until sold] >= -20 &&
            'Days'[Days until sold] <= 10
        )
    )
VAR Endresult = GrandTotal * 0.25
RETURN
    Endresult

This way, the filter is baked into the measure and you can safely remove the slicer from the report page.

If you also want to include something like your _NumberofValues logic, you can nest another CALCULATE or add it as a separate variable depending on how you want to use it in the final result.

Let me know if you want help combining both into one measure.

If my response resolved your query, kindly mark it as the Accepted Solution to assist others. Additionally, I would be grateful for a 'Kudos' if you found my response helpful.
translation and formatting supported by AI

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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.

Top Solution Authors