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! Learn more

Reply
Anonymous
Not applicable

How to write dax expression that filter dates in Power BI

Please I have this block of code in C#, I want to rewrite this in Power BI, but do not know how to filter the workdate.

 

var pallets = from a in _context.WorkRecordFacts
                      join b in _context.Activities on a.ActivityId equals b.Id
                      join c in _context.Buildings on a.BuildingId equals c.Id
                      join d in _context.BusinessUnits on c.BusinessUnitId equals d.Id
                      join e in _context.EmployeeStatuses on a.EmployeeId equals e.EmployeeId
                      join f in _context.Positions on e.PositionId equals f.Id
                      join g in _context.Uoms on a.Uomid equals g.Id
                      where a.WorkDate >= e.StartDate && a.WorkDate <= e.EndDate
                      where a.WorkDate != DateTime.Parse("0001-01-01")
                      where a.WorkDate >= model.StartDate && a.WorkDate < model.EndDate
                      where f.Code != "CSR"
                      where b.ReportingType == "Regular"

This is the part I need help with

Olumeedeh_0-1670879732876.png

This is my dax but the output is not correct.

TotalDHrs =
               var employee = [EmployeeId]
               var workDate = [WorkDate]
               var statuses = FILTER(ALL(EmployeeStatuses),
               EmployeeStatuses[StartDate] <= workDate
               && EmployeeStatuses[EndDate] >= workDate
               && EmployeeStatuses[EmployeeId] = employee)
               var result = CALCULATE(SUM(WorkRecordFacts[DurationHours]),
              statuses, WorkRecordFacts[PositionCode] IN {"WHSE", "TMP", "SPT"}, WorkRecordFacts[ActivityCode] <> "CS")
              return result
 
Olumeedeh_1-1670880297085.png

 

I also need to arrange the workday in the right order. Any help will be appreciated.

 

 

 

 

2 REPLIES 2
Anonymous
Not applicable

Hi @Anonymous,

Can you please share a pbix or some dummy data that keep the raw data structure and relationship mappings? It should help us clarify your scenario and test to coding formula.

How to Get Your Question Answered Quickly  

Regards,

Xiaoxin Sheng

Anonymous
Not applicable

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.