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
skills29
Frequent Visitor

DAX measure based on a value

Hello,

 

I have a table f_project_status which has a column called [Suspended/InExecution] that classifies if a project is suspended or in execution. I'm trying to create a measure to put in a matrix that shows me projects which is in execution in a month and in the previous month this project was suspended. I got this measure here:

Projects_Stopped_InExecution =
VAR PreviousMonth = EOMONTH(MAX(d_calendar[Date]), -1)
RETURN
    CALCULATE(
        COUNTROWS(f_project_status),
        f_project_status[Suspended/InExecution] = "In Execution",
        INTERSECT(
            VALUES(f_project_status[ProjectName]),
            CALCULATETABLE(
                VALUES(f_project_status[ProjectName]),
                PREVIOUSMONTH(d_Calendar[Date])
            )
        )
    )
 
It partially works because this measure also gets projects which is "In Execution" in a month and was also "In Execution" in the previous month, and i just want to projects which is "In Execution" in a month and was only "Suspended" in the previous month.
 
Could someone help me please? Thanks.
1 ACCEPTED SOLUTION
skills29
Frequent Visitor

I already solved, for those who might be useful, here's the measure:

Projects_Suspended_InExecution =
VAR PreviousMonth = EOMONTH(MAX(d_calendar[Date]), -1)
VAR Suspended_projects_last_month =
    CALCULATETABLE(
        VALUES(f_status_project[ProjectName]),
        f_status_project[Suspended/InExecution = "Suspended",
        PREVIOUSMONTH(d_calendar[Date])
    )
VAR InExecutionProjectsNextMonth =
    CALCULATETABLE(
        VALUES(f_status_project[ProjectName]),
        f_status_project[Suspended/InExecution = "InExecution",
        ALL(d_calendar),
        d_calendar[Date]> PreviousMonth && d_calendar[Date] <= EOMONTH(PreviousMonth, 1)
    )

RETURN
    COUNTROWS(
        INTERSECT(Suspended_projects_last_month, InExecutionProjectsNextMonth)
    )

View solution in original post

1 REPLY 1
skills29
Frequent Visitor

I already solved, for those who might be useful, here's the measure:

Projects_Suspended_InExecution =
VAR PreviousMonth = EOMONTH(MAX(d_calendar[Date]), -1)
VAR Suspended_projects_last_month =
    CALCULATETABLE(
        VALUES(f_status_project[ProjectName]),
        f_status_project[Suspended/InExecution = "Suspended",
        PREVIOUSMONTH(d_calendar[Date])
    )
VAR InExecutionProjectsNextMonth =
    CALCULATETABLE(
        VALUES(f_status_project[ProjectName]),
        f_status_project[Suspended/InExecution = "InExecution",
        ALL(d_calendar),
        d_calendar[Date]> PreviousMonth && d_calendar[Date] <= EOMONTH(PreviousMonth, 1)
    )

RETURN
    COUNTROWS(
        INTERSECT(Suspended_projects_last_month, InExecutionProjectsNextMonth)
    )

Helpful resources

Announcements
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

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.