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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
Anonymous
Not applicable

Set a conditional flag

Hello!

I have a table where I have period wise project wise finance data. I need to set up a flag (Calculated column) Active/Inactive based on the value of one column called Turnover. The condition is if there is a change (+/-) in the Turnover value for a project for last 3 months then the set the project as Active else set it Inactive. How can I write the condition?

 

Regards

Pia

1 ACCEPTED SOLUTION
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

To create a calculated column as below.

flag = 
VAR last3month =
    EDATE ( TODAY (), -3 )
VAR disc =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Turnover ] ),
        FILTER (
            'Table',
            'Table'[project_id] = EARLIER ( 'Table'[project_id] )
                && 'Table'[Date] >= last3month
                && 'Table'[Date] <= TODAY ()
        )
    )
RETURN
    IF (
        'Table'[Date] >= last3month
            && 'Table'[Date] <= TODAY (),
        IF ( disc > 1, "Active", "Inactive" ),
        BLANK ()
    )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.

View solution in original post

5 REPLIES 5
Ashish_Mathur
Super User
Super User

Hi,

Why do you want that as a calculated column and not a measure?


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
v-frfei-msft
Community Support
Community Support

Hi @Anonymous ,

 

To create a calculated column as below.

flag = 
VAR last3month =
    EDATE ( TODAY (), -3 )
VAR disc =
    CALCULATE (
        DISTINCTCOUNT ( 'Table'[Turnover ] ),
        FILTER (
            'Table',
            'Table'[project_id] = EARLIER ( 'Table'[project_id] )
                && 'Table'[Date] >= last3month
                && 'Table'[Date] <= TODAY ()
        )
    )
RETURN
    IF (
        'Table'[Date] >= last3month
            && 'Table'[Date] <= TODAY (),
        IF ( disc > 1, "Active", "Inactive" ),
        BLANK ()
    )

Capture.PNG

 

Community Support Team _ Frank
If this post helps, then please consider Accept it as the solution to help the others find it more quickly.
Anonymous
Not applicable

Hello @v-frfei-msft 

the data type for project nr. has changed to integer to string. and now the formula doesnt work. how can i change the formula?

 

 

Anonymous
Not applicable

1. Create Quick measure  as shown in the picture.
2. Pass only Dates Dim/Calendar table date as Date value
3. Value field as 'Turnover
4. Power BI Creates a Measure [Turnover MoM%]

Note: If you dont have CALENDAR table, manully derive the value MoM%

5. using this Measure derive your desired calculated column as below:
StatusFlag = IF([Turnover MoM%] = 0,"Inactive", "Active")Mom%.png

Anonymous
Not applicable

Hi @Anonymous 

But where can I define that comapre the values for only last 3 months?

 

Regards

Pia

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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