Forum Discussion

V3Rn3r_8-6's avatar
V3Rn3r_8-6
Frequent Visitor
2 years ago
Solved

DAX formula

Hello, Each row is a single order that was made during a shift that is visible in the "Směna 45-45" column on a specific day that is visible in the "Datum ZN" column and by a specific person by name...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi V3Rn3r_8-6 

    Use measure instead of calculate column, pbix file attached.


     

     

    Best Regards,

    Jayleny

     

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

  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi V3Rn3r_8-6 

     

    Please try the following calculate column:

    Realllll = 
    VAR _count = CALCULATE(COUNTROWS('Table'),FILTER(ALL('Table'),'Table'[Name]=EARLIER('Table'[Name])&&'Table'[Date]=EARLIER('Table'[Date])))
    RETURN
        IF (
            CALCULATE (
                SUM ( 'Table'[Total Orders on shift] ),
                FILTER (
                    ALL ( 'Table' ),
                    'Table'[Name] = EARLIER('Table'[Name])
                        && 'Table'[Shift] = "O" &&'Table'[Date]=EARLIER('Table'[Date])
                )
            )
                > CALCULATE (
                    SUM ( 'Table'[Total Orders on shift] ),
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Name] = EARLIER('Table'[Name])
                            && 'Table'[Shift] = "N" &&'Table'[Date]=EARLIER('Table'[Date])
                    )
                ),
            _count&"x"&"O",
            IF (
                CALCULATE (
                    SUM ( 'Table'[Total Orders on shift] ),
                    FILTER (
                        ALL ( 'Table' ),
                        'Table'[Name] = EARLIER('Table'[Name])
                            && 'Table'[Shift] = "N" &&'Table'[Date]=EARLIER('Table'[Date])
                    )
                )
                    > CALCULATE (
                        SUM ( 'Table'[Total Orders on shift] ),
                        FILTER (
                            ALL ( 'Table' ),
                            'Table'[Name] = EARLIER('Table'[Name])
                                && 'Table'[Shift] = "R" &&'Table'[Date]=EARLIER('Table'[Date])
                        )
                    ),
                _count&"x"&"N",
                _count&"x"&"R"
            )
        )

     

     

     

     

     

     

     

    Best Regards,

    Jayleny

     

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