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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
obriaincian
Resolver I
Resolver I

Using Selected Value from a slicer within a measure

Hi All,

 

I'm in need of some help.

 

First let me outline the data.

I have 2 columns Product Days until Expiry date

 

I also have a calculated column which uses a switch statement that looks at the Days until Expiry date column and and assigns labels e.g. if the Product has more than 100 days until expiry then it will be assigned the label "No Orders required"

 

Current Code

 

 

 

ProductLabels =
SWITCH (
    TRUE(),
    isblank('DF'[Days until Expiry date]),"No Date available",
    'DF'[Days until Expiry date]>=100, "No Orders required",
    'DF'[Days until Expiry date]<100 "Orders Required"
)

 

 

 

 

The issue is that this month we might label products with < 100 days until expiry as "Orders Required" and next month this might be pushed to < 150 days

 

I want to create a slicer which will have 100,150,200,250 days. when the user selects one I want the calculated column above to be dynamically adjusted.

 

e.g. it will look like this

ProductLabels =
VAR SV = SELECTEDVALUE(SlicerTable[Values])
SWITCH (
TRUE(),
    isblank('DF'[Days until Expiry date]),"No Date available",
    'DF'[Days until Expiry date]>=SV , "No Orders required",
    'DF'[Days until Expiry date]<SV ,"Orders Required"
)

 

And the final result will be a distinct count of the products by label

e.g

Label                       Distinct Count of Products

No Change                               10

Orders Required                       20

No Orders Required                 30

 

I'm aware that selectedvalue cannot be used within calculated columns so I'm looking to create a measure that contains a distinct count.

 

 

Thanks in advance

 

1 REPLY 1
amitchandak
Super User
Super User

@obriaincian , You have created a measure and use dynamic segmentation

 

Dynamic Segmentation Bucketing Binning
https://community.powerbi.com/t5/Quick-Measures-Gallery/Dynamic-Segmentation-Bucketing-Binning/m-p/1...


Dynamic Segmentation, Bucketing or Binning: https://youtu.be/CuczXPj0N-k

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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