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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

Reply
ITManuel
Responsive Resident
Responsive Resident

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.



Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.