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

Compete to become Power BI Data Viz World Champion! First round ends August 18th. Get started.

Reply
aj1107
Advocate I
Advocate I

calculated column logic.

I need to create a calculated column based on below condition. Not sure how to get the entire planid logic using calc column.

i tried to create a calctable of below condition and then update using planid=related(planid). Is there a way to get it without calctable.

 

condition:

if cdate<=Monthlydate and st="open"  then update 1 for the entire planid (all 3 rows of planid=1)

 

id,cdate,Monthlydate,st, calccolumn

1,01/13/2017,01/31/2017,open,1

1,01/13/2017,02/28/2017,closed,1

1,01/13/2017,03/31/2017,closed,1

4,01/13/2017,04/30/2017,closed,0

 

Thank you.

2 ACCEPTED SOLUTIONS

Hey,

 

you can find a little example

 

For this table:

table.png

 

A caclculated column using this DAX statement:

calcColumn = 
if(
    calculate(
        count('Table1'[id]),
        FILTER(
            ALLEXCEPT('Table1',Table1[id]),
            'Table1'[right] > 'Table1'[left] && 'Table1'[literal] = "yes"
        )
   ) >= 1, 
   1, 
   2
)

Returns these values:

table - result.png 

 

Hope this helps

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

View solution in original post

@aj1107,

 

You may refer to the following DAX as well.

calccolumn =
IF (
    COUNTROWS (
        FILTER (
            Table1,
            Table1[id] = EARLIER ( Table1[id] )
                && Table1[cdate] <= Table1[Monthlydate]
                && Table1[st] = "open"
        )
    )
        > 0,
    1,
    0
)
Community Support Team _ Sam Zha
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

4 REPLIES 4
TomMartens
Super User
Super User

Hey,

 

just for my understanding, i try to rephrase your requirement

 

  • even if row 2 and 3 do not satisfy the condition st = open, the value for the calculated column is 1 because row 1 satisfies this condition
  • if one row of a group (grouped by id) satisfies the condition, the value for all rows in the group becomes 1

Is my understanding correct?

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

yes. if atleast one row of a group(id) satisfies then the entire group id (planid=1) is 1.

@aj1107,

 

You may refer to the following DAX as well.

calccolumn =
IF (
    COUNTROWS (
        FILTER (
            Table1,
            Table1[id] = EARLIER ( Table1[id] )
                && Table1[cdate] <= Table1[Monthlydate]
                && Table1[st] = "open"
        )
    )
        > 0,
    1,
    0
)
Community Support Team _ Sam Zha
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hey,

 

you can find a little example

 

For this table:

table.png

 

A caclculated column using this DAX statement:

calcColumn = 
if(
    calculate(
        count('Table1'[id]),
        FILTER(
            ALLEXCEPT('Table1',Table1[id]),
            'Table1'[right] > 'Table1'[left] && 'Table1'[literal] = "yes"
        )
   ) >= 1, 
   1, 
   2
)

Returns these values:

table - result.png 

 

Hope this helps

 



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

Check out the August 2025 Power BI update to learn about new features.

August 2025 community update carousel

Fabric Community Update - August 2025

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

Top Solution Authors