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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Calculated columns and slicer value

Hi, 

 

As a slicer value cannot be passed on to calculated column to make it dynamic, what would be the best work-around to below issue?

 

The column "Report_product" should be dependable on the date selected in the Date-slicer. In below example I have used today's date, but the date would need to be dynamic in order to be able to report historical numbers correctly.

 

celenius_1-1641296246128.png

 

 

Br, Chris

1 ACCEPTED SOLUTION
v-yetao1-msft
Community Support
Community Support

Hi @Anonymous 

Calculated column values are not responsive to filter selection or parameters. So if you want to return a dynamic value filtered by slicer , my suggestion is to create a measure instead of calculated column.

(1)Create a calendar date table to return a date column .

Calendar Date = CALENDAR(DATE(2021,12,28),DATE(2021,12,31))

(2)Add a slicer with field 'Calendar Date'[Date] ,then you can filter data table with the dynamic date .

(3)Create a measure with the dynamic date from Calendar Date table.

Measure = IF(SELECTEDVALUE('Table'[Exp.date_q])=BLANK(),SELECTEDVALUE('Table'[Product_y]),
IF(and(SELECTEDVALUE('Calendar Date'[Date])>SELECTEDVALUE('Table'[Exp.date_y]),SELECTEDVALUE('Calendar Date'[Date])<SELECTEDVALUE('Table'[Exp.date_q])),SELECTEDVALUE('Table'[Product_y]),
IF(SELECTEDVALUE('Calendar Date'[Date])>SELECTEDVALUE('Table'[Exp.date_q]),SELECTEDVALUE('Table'[Product_m]))))

The final result is as shown :

Ailsamsft_0-1641522403565.png

Ailsamsft_1-1641522403566.png

I have attached my pbix file , you can refer to it.

 

Best Regard

Community Support Team _ Ailsa Tao

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

3 REPLIES 3
v-yetao1-msft
Community Support
Community Support

Hi @Anonymous 

Calculated column values are not responsive to filter selection or parameters. So if you want to return a dynamic value filtered by slicer , my suggestion is to create a measure instead of calculated column.

(1)Create a calendar date table to return a date column .

Calendar Date = CALENDAR(DATE(2021,12,28),DATE(2021,12,31))

(2)Add a slicer with field 'Calendar Date'[Date] ,then you can filter data table with the dynamic date .

(3)Create a measure with the dynamic date from Calendar Date table.

Measure = IF(SELECTEDVALUE('Table'[Exp.date_q])=BLANK(),SELECTEDVALUE('Table'[Product_y]),
IF(and(SELECTEDVALUE('Calendar Date'[Date])>SELECTEDVALUE('Table'[Exp.date_y]),SELECTEDVALUE('Calendar Date'[Date])<SELECTEDVALUE('Table'[Exp.date_q])),SELECTEDVALUE('Table'[Product_y]),
IF(SELECTEDVALUE('Calendar Date'[Date])>SELECTEDVALUE('Table'[Exp.date_q]),SELECTEDVALUE('Table'[Product_m]))))

The final result is as shown :

Ailsamsft_0-1641522403565.png

Ailsamsft_1-1641522403566.png

I have attached my pbix file , you can refer to it.

 

Best Regard

Community Support Team _ Ailsa Tao

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

Anonymous
Not applicable

@v-yetao1-msft  Hi, thanks a lot, your suggested solution works fine in obtaining the correct names for the product depending on the selected date. Next step is to add data to the visual from another table based on the product names in the measure, how would that measure look like? (relationship between the measure and column?)

amitchandak
Super User
Super User

@Anonymous , You need to dynamic segmentation of binning

 

check example

 

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


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

 

https://radacad.com/dynamic-banding-or-grouping-in-power-bi-using-dax-measures-choose-the-size-of-bins
https://www.credera.com/blog/technology-solutions/creating-aging-report-using-a-user-selected-date-in-power-bi/

https://www.daxpatterns.com/dynamic-segmentation/

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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

Top Solution Authors