Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

Vote for your favorite vizzies from the Power BI Dataviz World Championship submissions. Vote now!

Reply
3s
Regular Visitor

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?
 
2 ACCEPTED SOLUTIONS
krishnakanth240
Power Participant
Power Participant

Hi @3s 

 

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

 

krishnakanth240_0-1768568976474.pngkrishnakanth240_1-1768569001980.png

 

View solution in original post

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.

Ashish_Mathur_0-1768619775581.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

View solution in original post

8 REPLIES 8
3s
Regular Visitor

Thanks @Ashish_Mathur and @krishnakanth240 both your solutions worked out for me!

v-aatheeque
Community Support
Community 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.

krishnakanth240
Power Participant
Power Participant

Hi @3s 

 

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

 

krishnakanth240_0-1768568976474.pngkrishnakanth240_1-1768569001980.png

 

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.

Ashish_Mathur_0-1768619775581.png


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/
ryan_mayu
Super User
Super User

@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?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




3s
Regular Visitor

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

JamieHolding
Resolver I
Resolver I

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?

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

Vote for your favorite vizzies from the Power BI World Championship submissions!

Sticker Challenge 2026 Carousel

Join our Community Sticker Challenge 2026

If you love stickers, then you will definitely want to check out our Community Sticker Challenge!

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.