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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
vitalijusb_sisp
Frequent Visitor

Power BI index column with multi condition

Hi,

 

I can't find the solution to calculate index column (NEW INDEX) by example (below).

Index start from 1 when changes Date or Parking or Direction.

I tried this DAX:

NEW INDEX = VAR _Date = Table[Date]
VAR _Direction = Table[Direction]
VAR _Parking = Table[Parking]
RETURN
CALCULATE(COUNT(Table[Date]); FILTER(Table; Table[Date] = _Date && Table[Direction] = _Direction && Table[Parking] = _Parking))

 

Could you can help?

 

IdDirectionDateTimeParkingNEW_INDEX
3248In2018-01-0207:15:05A1
3249In2018-01-0207:56:24A2
3250In2018-01-0208:06:06A3
3251In2018-01-0208:21:19A4
3258Out2018-01-0217:14:04A1
3260Out2018-01-0217:17:44A2
3261Out2018-01-0217:58:46A3
3263Out2018-01-0219:59:54A4
1766In2018-01-0207:12:19B1
1767In2018-01-0211:33:17B2
1768Out2018-01-0214:56:59B1
1769Out2018-01-0217:27:29B2
3269In2018-01-0307:14:02A1
3270In2018-01-0307:20:03A2
3271In2018-01-0307:39:35A3
3277Out2018-01-0310:50:45A1
3278Out2018-01-0311:11:17A2
3281Out2018-01-0317:03:16A3
3287Out2018-01-0320:00:18A4
5153In2018-01-0318:14:46C1
5154In2018-01-0318:28:44C2
5155In2018-01-0318:30:11C3
5184Out2018-01-0320:28:30C1
5185Out2018-01-0321:08:00C2
5186Out2018-01-0321:08:13C3

 

Thanks

 

Vitalijus

1 ACCEPTED SOLUTION
Anonymous
Not applicable

[New Index] =
var __date = T[Date]
var __direction = T[Direction]
var __parking = T[Parking]
var __time = T[Time]
var __index =
	COUNTROWS(
		FILTER(
			T,
			TRUE()
			&& T[Date] = __date
			&& T[Direction] = __direction
			&& T[Parking] = __parking
			&& T[Time] <= __time
		)
	)
return
	__index

Best

Darek

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

[New Index] =
var __date = T[Date]
var __direction = T[Direction]
var __parking = T[Parking]
var __time = T[Time]
var __index =
	COUNTROWS(
		FILTER(
			T,
			TRUE()
			&& T[Date] = __date
			&& T[Direction] = __direction
			&& T[Parking] = __parking
			&& T[Time] <= __time
		)
	)
return
	__index

Best

Darek

Thank you very much ! That's great !

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

Find out what's new and trending in the Fabric Community.