cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
celenius
Helper I
Helper I

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
Ailsa-msft
Community Support
Community Support

Hi @celenius 

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
Ailsa-msft
Community Support
Community Support

Hi @celenius 

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.

@Ailsa-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

@celenius , 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/1...


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-bi...
https://www.credera.com/blog/technology-solutions/creating-aging-report-using-a-user-selected-date-i...

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.



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors
Top Kudoed Authors