Forum Discussion

CoTheiss's avatar
CoTheiss
Frequent Visitor
3 years ago

Calculated column with max(selectedvalue) from field

Hey guys

 

I am trying to create a True/False field based on different constraints with one constraint that should be dynamic due to a field selection. 
In the past I worked with other BI-tools, however I started with PowerBI few months ago and my personal guess is, that the solution is either super easy or I need to completely rewrite it, as "you cannot do this in calculated columns".

 

Here is the column without the dynamic constraint (this works fine):

IsExpiring =
if( LEN('Periods'[PeriodFrom])<1 || LEN('Periods'[PeriodTo])<1,
 FALSE,
if(
'Periods'[PeriodFrom]<=TODAY() && 'Periods'[PeriodTo]>=today() && ('Periods'[PeriodTo]<=today()+20)
,TRUE,
FALSE
))

 

Now, I want to make this dynamic:

By replacing the +20 by the max selected value in the field Sel_ExpiryDate[Days], which is a data island (no relations to any other table) solely for selecting the maximum number of days that should be added.

 

While the posted calculated table is working fine, it does calculate the max(Sel_ExpiryDate[Days]) so far, whatever I try.

Tried so far: 

- entered max(Sel_ExpiryDate[Days]) directly

- created a measure with max(Sel_ExpiryDate[Days]) in the Sel_ExpiryDate table

-created a measure with max(Sel_ExpiryDate[Days]) in the Period table

 

2 Replies

  • HotChilli's avatar
    HotChilli
    Icon for Community Champion rankCommunity Champion

    "solely for selecting the maximum number of days" -> How is this selected? In a slicer or filter?  If so, the calculated column won't react to that.

    A measure would react to it.

  • CoTheiss's avatar
    CoTheiss
    Frequent Visitor

    HotChilli  yes it is a slicer with a slider.

     

    I wanted to give the user the flexibility to choose the number of days. 

     

    If there are better solutions to not just have a fixed measure but instead give the user some flexibility here - that would be awesome 🙂