Forum Discussion

3s's avatar
3s
Regular Visitor
7 months ago
Solved

No results

Hi, I am new in here and in Dax. I couln't find a similar question, so hopefully someone can help.

I am trying to achieve the same as Excel: countif(B:B;B2;A:A;D2).

This is what I am doing:

Count =
VAR vB = SELECTEDVALUE('Table'[ID])
VAR vD = SELECTEDVALUE('Table'[Year+1])
RETURN
COUNTROWS (
    FILTER (
        ALL ( 'Table' ),
        'Table'[ID] = vB
            && 'Table'[Year] = vD
    )
)
Unfortunately there are no results.
What am I doing wrong?
 
  • Hi 3s 

     

    Have tried this in desktop with your sample data. Please let me know the exact requirement/logic if it does not work.

     

     

  • Hi,

    These calculated column formulas work

    =CALCULATE(COUNTROWS(Data),FILTER(Data,Data[member]=EARLIER(Data[member])&&Data[year]=EARLIER(Data[year+1])))+0

     

    =CALCULATE(COUNTROWS(Data),FILTER(Data,Data[member]=EARLIER(Data[member])&&Data[year]=EARLIER(Data[year-1])))+0

    Hope this helps.

8 Replies

  • 3s's avatar
    3s
    Regular Visitor

    Now I am getting results. Unfortunately it is not wat I am looking for.

    I want to calculate the number of starting and stopping members. 

    The columns 'year+1' and 'year-1' are calculated with column 'year'.

    The columns 'also member following year' and 'was member last year' are the columns I am looking for a DAX-formula.

    In Excel it would be for 'also member following year': countifs(B:B;B2;A:A;C2)

    And for 'was member last year': countifs(B:B;B2;A:A;E2)

    If there are other options I am interested as well.

     

    Column AColumn BColumn CColumn DColumn EColumn F
    yearmemberyear+1also member following yearyear-1was member last year
    2016K58PR5Q2017020150
    2018K58PR5Q2019120170
    2019K58PR5Q2020120181
    2020K58PR5Q2021120191
    2021K58PR5Q2022120201
    2022K58PR5Q2023120211
    2023K58PR5Q2024120221
    2024K58PR5Q2025120231
    2025K58PR5Q2026020241
    2022K65RR1W2023120210
    2023K65RR1W2024120221
    2024K65RR1W2025120231
    2025K65RR1W2026020241
    2018K36GO4B2019020170
    2020K36GO4B2021020190
    2022K36GO4B2023020210
    2024K36GO4B2025020230
    2019K33AM4I2020120180
    2020K33AM4I2021120191
    2021K33AM4I2022020201
    2025K33AM4I2026020240
    2022K33QZ4N2023020210
    2023K33RX7X2024020220
    2025K34AN4J2026020240
    2025K35HR4A2026020240
    2024K52XJ8M2025020230
    2021K33WA1O2022020200
    2017K32SV1D2018020160
    2016K34DF6S2017020150
    2019K35UQ2U2020020180
    • Hi,

      These calculated column formulas work

      =CALCULATE(COUNTROWS(Data),FILTER(Data,Data[member]=EARLIER(Data[member])&&Data[year]=EARLIER(Data[year+1])))+0

       

      =CALCULATE(COUNTROWS(Data),FILTER(Data,Data[member]=EARLIER(Data[member])&&Data[year]=EARLIER(Data[year-1])))+0

      Hope this helps.

  • Hi 3s 

     

    Have tried this in desktop with your sample data. Please let me know the exact requirement/logic if it does not work.

     

     

  • Count =

    VAR vB = SELECTEDVALUE('Table'[ID])

    VAR vD = SELECTEDVALUE('Table'[Year+1])

    RETURN

    IF(

    NOT(ISBLANK(vB)) && NOT(ISBLANK(vD)),

    COUNTROWS(

    FILTER(

    ALLEXCEPT('Table', 'Table'[ID], 'Table'[Year+1]),

    'Table'[ID] = vB && 'Table'[Year] = vD

    )

    ),

    BLANK()

    )

    It's a little hard to test without the data but can you try this?

  • 3s's avatar
    3s
    Regular Visitor

    Thanks. Unfortunately I am getting the message about a circulair dependency detected: Table[Count]

  • 3s 

    maybe you can try this to create a calculated column.

     

    Count =
    CALCULATE(
    COUNTROWS('Table'),
    FILTER(
    'Table',
    'Table'[ID] = EARLIER('Table'[ID])
    && 'Table'[Year] = EARLIER('Table'[Year])
    )
    )

     

    if this does not work, could you pls provide some sample data and expected output?

    could you pls provide some sample data and expected output?

  • v-aatheeque's avatar
    v-aatheeque
    Icon for Community Support rankCommunity Support

    Hi 3s 

    Following up to confirm if the earlier responses addressed your query. If not, please share your questions and we’ll assist further.