cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
ITManuel
Helper V
Helper V

How to ignore row context but keep filter context in calculated column

Hi,

 

I would like to identify the minimum data in a table while considering also the date range selected by a slicer.

 

As a measure the following code provides the expected result.

 

FirstDateSelected = 
calculate(
    min(Data[Date]),
    ALLSELECTED(Data[Date])
)

 

 However, the same code does not work with a calculated column, I'm assuming because of the automatic row context of calculated columns. 

 

I tried 

 

FirstDateSelectedCalculatedColumn = 
calculate(
    min(Data[Date]),
    allselected(Data)
)

 

in a calculated column, it seems to ignore the row context but does not consider anymore the selected dates in the slicer.

 

How can I ignore the row context keeping the filter context in a calculated column?

 

Thanks in advance

 

 

1 ACCEPTED SOLUTION
Ashish_Mathur
Super User
Super User

Hi,

Calculated column formulas do not respond to changes in slicers.  Calculated columns are recalculated only when you press Refresh.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

3 REPLIES 3
v-jingzhang
Community Support
Community Support

Hi @ITManuel 

A calculated column is computed when it's created and during data refresh. Then the column results are stored in the data model. It does not depend on user interaction in the report such as filters, slicers and so on.

If you want to get different results based on slicers, you should use measures rather than calculated columns. See more differences between them and when to use each one:

https://www.sqlbi.com/articles/calculated-columns-and-measures-in-dax/

https://blog.enterprisedna.co/power-bi-calculated-column-vs-measure-a-comparison/

 

Regards,
Community Support Team _ Jing Zhang
If this post helps, please consider Accept it as the solution to help other members find it.

Ashish_Mathur
Super User
Super User

Hi,

Calculated column formulas do not respond to changes in slicers.  Calculated columns are recalculated only when you press Refresh.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
parry2k
Super User
Super User

@ITManuel you need to add another disconnected table for the slicer and then use that to get the minimum date.

 

Check my latest blog post Compare Budgeted Scenarios vs. Actuals I would  Kudos if my solution helped. 👉 If you can spend time posting the question, you can also make efforts to give Kudos to whoever helped to solve your problem. It is a token of appreciation!

Visit us at https://perytus.com, your one-stop-shop for Power BI-related projects/training/consultancy.






Did I answer your question? Mark my post as a solution.

Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.





Helpful resources

Announcements
May 2023 update

Power BI May 2023 Update

Find out more about the May 2023 update.

Submit your Data Story

Data Stories Gallery

Share your Data Story with the Community in the Data Stories Gallery.

Top Solution Authors