Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more
I wrote some lines of pseudocode that i wuold like to translate in power query code.
This code would help me to create a new column in CAR_ MILEAGE table with the name of the employee or the organizational site that had the car in a certain period.
UPPER CASE NAME=TABLES
.lower case name= atttributes
TABLE[i]= row in position i of table TABLE
.fromDate.month= month of the attribute fromDate that is in Date format.
CAR_MILEAGE has already a column called month that contains the number of the month
var found=false
for each row(i) in CAR_MILEAGE <-(looping)
table.selectrows(table as CAR_ASSIGNMENT,condition as CAR_ASSIGNMENT.car==CAR_MILEAGE[i].car) as TAB1 //get all the row that satisfy the condition in a list/table
found=false;
for each row(j) in TAB1 <-(looping)
if(CAR_MILEAGE[i].month>= TAB1[j].fromeDate.month && CAR_MILEAGE[i].year>= TAB1[j].fromDate.year)
&& (TAB1[j].toDate=="" or (CAR_MILEAGE[i].month<= TAB1[j].toDate.month && CAR_MILEAGE[i].year<= TAB1[j].toDate.year))
then found=true
if TAB1[j].businessSite=="" return TAB1[j].employee
else return TAB1[j].businessSite
else continue
if(found==false)
return "err"
else continue
Can you please post sample data also? - How to provide sample data
👍 It's been a pleasure to help you | Help Hours: 11 AM to 9 PM (UTC+05:30)
How to get your questions answered quickly -- How to provide sample data
this is car mileage:
this is car assignment:
NOTE: in car assignment the fromDate start always at the start of a month and ends at the end of a month or is still going if the value is emprty.
I want to retrieve the business site (LA, NY etcc..) or the employee(joe,...) which was using the company car
The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!