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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
User2
Frequent Visitor

Count with filter

Hey guys,

 

I am new to Power BI and I need help with the following problem.

 

I have a column1 with journeys and in the second column I counted them using the aggregation count.

In the third column I switched the beginning and the end of the journey.

Now, in column 4 I want to lookup how many times I can find the exact journey back.

 

Is there any way to do it?

 

Thanks, Peter

Journeyno. of journeyjourney backno. of journey back

Frankfurt - Hamburg

this column is no problemHamburg - Frankfurtthis should be 0
London - Glasgow Glasgow - Londonthis should be 1
Glasgow - London London - Glasgowsame
Rome - Budapest Budapest - Rome0
Frankfurt - Hamburg Hamburg - Frankfurt0
1 ACCEPTED SOLUTION
User2
Frequent Visitor

I solved the problem by duplicating the "journey" column, then grouping it and finally adding a new calculated column in the original table using a Lookupvalue.

View solution in original post

5 REPLIES 5
Anonymous
Not applicable

Hi @User2 ,

 

Like this?

vmengzhumsft_0-1662707146530.png

You can create a measure like this :

no.of journey back = var _back= CALCULATE(COUNTROWS('Table'),FILTER('Table',SELECTEDVALUE('Table'[Journey back])in ALL('Table'[Journey])))
return if(_back<>0,_back,0)

 

I also attached my pbix file, you can refer it.

 

Best regards,

Community Support Team Selina zhu

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

Hi @Anonymous ,

 

unfortunately, it doesn't yield the result I want to achieve.

Somehow, I am unable to upload files, so I uploaded images of my data and the result from your measure.

 

table in exceltable in excelresult in power biresult in power bi

 

I want to create a delta, which is simply the difference between # of journeys and # of journeys back.

 

In my pbix file, Frankfurt - Hamburg is counted 2 times and Hamburg - Frankfurt is counted 8 times.
So, the first row should look like this:

 

Journey# journeysjourney back# journeys backdelta
Frankfurt - Hamburg2Hamburg - Frankfurt8-6

 

Any other idea how I can achieve this result?

 

Appreciate your effort!

Anonymous
Not applicable

Hi @User2 ,

 

If your table can present this one-to-one correspondence, then it is easy to do the calculations you want.

vmengzhumsft_0-1663052317358.png

just create a measure to calculate,like this

vmengzhumsft_1-1663052524174.png

value = SUM('Table'[number of Journey ])-SUM('Table'[number of back])

Since the calculation is for the same row, it may be can't meet your needs when there is no correspondence between journey and journey back.

 

Best regards,

Community Support Team Selina zhu

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

 

Hi @Anonymous ,

 

the problem is not how I calculate my value, the problem is how I can extract the number of journeys back out of the column "no. of journeys". All I receive is the same values for both columns.

 

Example:

I only get the values if column "journey" and "journey back" are identical, e.g. "F - F" and "F - F" but if it is "F- H" to "H- F" I cannot extract the value. 

 

How did you count the number of journeys back? I don't get how I can count them without receiving the exact same values as for the column "journey".

 

Thanks for your help.

User2
Frequent Visitor

I solved the problem by duplicating the "journey" column, then grouping it and finally adding a new calculated column in the original table using a Lookupvalue.

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 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.

Top Solution Authors