Forum Discussion

gkarlo's avatar
gkarlo
Icon for Helper I rankHelper I
2 years ago
Solved

Count orders with specific conditions

I hope someone may assist me with this... Currently I have a table of projects that can be Won, Lost or No Realized, the column of this os really exisiting, the problem that I have is that the same ...
  • govindarajan_d's avatar
    2 years ago

    Hi gkarlo,

     

    Create a calculated column like this:

     

    StatusValue =
    IF (
        SampleData[Status] = "No Realized",
        1,
        IF ( SampleData[Status] = "Lost", 2, 3 )
    )

     

     

    And then create 3 measures like this:

     

    No of Won =
    COUNTROWS (
        FILTER (
            SUMMARIZE (
                SampleData,
                SampleData[Project],
                "MaxStatus", MAX ( SampleData[StatusValue] )
            ),
            [MaxStatus] = 3
        )
    )
    No of Lost =
    COUNTROWS (
        FILTER (
            SUMMARIZE (
                SampleData,
                SampleData[Project],
                "MaxStatus", MAX ( SampleData[StatusValue] )
            ),
            [MaxStatus] = 2
        )
    )
    No of No Realized =
    COUNTROWS (
        FILTER (
            SUMMARIZE (
                SampleData,
                SampleData[Project],
                "MaxStatus", MAX ( SampleData[StatusValue] )
            ),
            [MaxStatus] = 1
        )
    )

     

     

    The same can be achieved using RANK formula also. 

     

    Tested:

     

    Upvote and accept as a solution if it helped!

     

  • govindarajan_d's avatar
    govindarajan_d
    2 years ago

    Hi gkarlo,

     

    Sorry about that. I missed to replace COUNTROWS.

     

    No of No Realized =
    SUMX (
        FILTER (
            ADDCOLUMNS(
            SUMMARIZE (
                SampleData,
                SampleData[Project],
                "MaxStatus", MAX ( SampleData[StatusValue] )
            ),
            "SumProject",SUMX(RELATEDTABLE(ProjectList),ProjectList[Price])
            ),
            [MaxStatus] = 1
        ),
    [SumProject]
    )