Forum Discussion

Srijit's avatar
Srijit
Regular Visitor
4 years ago
Solved

Need help on DAX

Need help on the below scenario   I have data for Year ,QTR,Mon,Week but the data(Total Count from Start) what we see is an accumiliated value. For Eg 2390 for Project 1 is not the count for that w...
  • v-yanjiang-msft's avatar
    4 years ago

    Hi Srijit ,

    According to your description, here's my solution.

    1.Create a date column.

    Date = FORMAT(DATE('Table'[Year],'Table'[Month Name],1),"yyyy-mm")

    2.Create a rank column based on date.

    Rank = RANKX(FILTER(ALL('Table'),'Table'[Project Name]=MAX('Table'[Project Name])),'Table'[Date],,ASC,Dense)

    3.Create the count per month measure.

    Count per Month = 
    VAR _Cur =
        MAXX (
            FILTER (
                ALL ( 'Table' ),
                'Table'[Project Name] = MAX ( 'Table'[Project Name] )
                    && 'Table'[Rank] = MAX ( 'Table'[Rank] )
            ),
            'Table'[Total Count from start]
        )
    VAR _Pre =
        MAXX (
            FILTER (
                ALL ( 'Table' ),
                'Table'[Project Name] = MAX ( 'Table'[Project Name] )
                    && 'Table'[Rank]
                        = MAX ( 'Table'[Rank] ) - 1
            ),
            'Table'[Total Count from start]
        )
    RETURN
        IF ( ISBLANK ( _Pre ), BLANK (), _Cur - _Pre )
    

    4.Create the count per qtr measure.

    Count per Qtr = 
    SUMX (
        FILTER (
            ALL ( 'Table' ),
            'Table'[Project Name] = MAX ( 'Table'[Project Name] )
                && 'Table'[QTR] = MAX ( 'Table'[QTR] )
        ),
        [Count per Month]
    ) / 2
    

    Get the expected result.

    As there isn't the start value here, so I show it blank.

    I attach my sample below for reference.

     

    Best Regards,
    Community Support Team _ kalyj

     

    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.