Power BI is turning 10, and we’re marking the occasion with a special community challenge. Use your creativity to tell a story, uncover trends, or highlight something unexpected.
Get startedJoin us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.
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
This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.
Check out the June 2025 Power BI update to learn about new features.
User | Count |
---|---|
17 | |
10 | |
8 | |
8 | |
7 |