Forum Discussion

selpaqm's avatar
selpaqm
Icon for Helper V rankHelper V
6 years ago
Solved

earlier function combine with other columns

Hi,

 

I have a table as below. 

Column uses 

"Column =
VAR _count= CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[salesman/country]=EARLIER('Table'[salesman/country])&&'Table'[Index]>=EARLIER('Table'[Index])))
VAR _count2=CALCULATE(COUNTROWS('Table'),FILTER('Table','Table'[salesman/country]=EARLIER('Table'[salesman/country])))
return if(_count=_count2,1,0)"

however, in case of method a and b is for same country and salesman need to be written as mixed.

as an example updated method column should be as below.

below you may find the related pbix file

example.pbix 

 

  • selpaqm , refer this can work as a new column

    Column =
    VAR _count= CALCULATE(DistinctCount([Method]) ,FILTER('Table','Table'[salesman/country]=EARLIER('Table'[salesman/country])))+0
    return if(_count>1,"Mixed", [method])

5 Replies

  • Greg_Deckler's avatar
    Greg_Deckler
    Icon for Community Champion rankCommunity Champion

    selpaqm First, DAX Formatter is your friend: https://www.daxformatter.com/

     

    Column =
      VAR __Table = 
        SUMMARIZE(
            FILTER (
                'Table',
                'Table'[salesman/country] = EARLIER ( 'Table'[salesman/country] ),
                [method]
            )
    RETURN
        IF ( COUNTROWS(__Table>1, "mixed", MAXX(__Table,[method]) )

    If not, share data as text in a table please. 

      

      • amitchandak's avatar
        amitchandak
        Icon for Super User rankSuper User

        selpaqm , refer this can work as a new column

        Column =
        VAR _count= CALCULATE(DistinctCount([Method]) ,FILTER('Table','Table'[salesman/country]=EARLIER('Table'[salesman/country])))+0
        return if(_count>1,"Mixed", [method])