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
VinnieHuub
New Member

Dynamic Category based on selected date

Hi all,

 

I'm trying to create a new category column to an existing table, but it needs to be calculated based on a date selected by the end user.

 

F.e. we have this simple table called Customer:

 

CustnrTypeLogindateBalance
1Joint1/1/2020100
2Joint1/5/202010000
3Single1/6/2020400
4Minor1/9/20200
5Minor1/12/202050000
6Single1/2/202110
7Self Employed1/3/202130
8SME1/8/202140

 

A new column needs to be added based on the logindate and a selected date. If the logindate <= selecteddate, then Yes else No.
(A calculated column is a possibility, but then the dataset needs to be refreshed every time)

I tried the following:

 

create a date table, not related to any other table, to be used as a slicer

 

create a new table based on the existing adding the logincategory:

 

LoginCat =
VAR OnDate = date(2020,1,16)
RETURN
CALCULATETABLE(
ADDCOLUMNS(CUSTOMER, "LoginCat", if(CUSTOMER[Logindate] <= OnDate, "Yes", "No"))
)
 This works fine with the date hard-coded:
VinnieHuub_0-1639085782891.png


But when I change the variable to = selectedvalue(calendar[date]) it doesn't pick up the selected date.

Any idea?

 

Thank you.

 

Vincent

1 ACCEPTED SOLUTION
v-zhangti
Community Support
Community Support

Hi, @VinnieHuub 

 

You can try the following methods.

Date = CALENDAR(DATE(2020,1,1),DATE(2021,8,31))

Measure:

Measure = 
IF (
    MAX ( 'Date'[Date] ) >= SELECTEDVALUE ( 'Customer'[Logindate] ),
    "Yes",
    "No"
)

vzhangti_0-1639553936229.pngvzhangti_1-1639553959477.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

View solution in original post

2 REPLIES 2
v-zhangti
Community Support
Community Support

Hi, @VinnieHuub 

 

You can try the following methods.

Date = CALENDAR(DATE(2020,1,1),DATE(2021,8,31))

Measure:

Measure = 
IF (
    MAX ( 'Date'[Date] ) >= SELECTEDVALUE ( 'Customer'[Logindate] ),
    "Yes",
    "No"
)

vzhangti_0-1639553936229.pngvzhangti_1-1639553959477.png

 

Best Regards,

Community Support Team _Charlotte

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

 

amitchandak
Super User
Super User

@VinnieHuub ,

First Create a measure

M1= if(Max(Table[logindate]) <= selectedvalue('Date'[Date]), "Yes", "No")

 

Create a table/Enter data, with two rows  Yes, No

or a new Table

Bucket = Union(row("Flag", "Yes") , rows("Flag", "No" ))

 

Create a measure now

sumx(filter(values(Table[Custnr]) , [M1] = max(Bucket[Flag]) ), Calculate(Sum(Table[Balance] )) )

 

 

 

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
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors