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
MODUser
Frequent Visitor

MCode or DAX measure to create filter or new column based on daily total comparison.

I have a daily data interval table and need assistance with MCode, a measure or custom column to assign "On Site" or "Off Site" based on criteria....where total Work time = total Other time for the entire day, assign "Off Site" else "On Site" and have the assignment for the day assigned to each interval for the individual.

 

MODUser_1-1675300712288.png   MODUser_2-1675301700430.png

 

 

 

1 ACCEPTED SOLUTION
alannavarro
Resolver I
Resolver I

Hello, did it in a lot of steps, hope it helps.


let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"Date", "Full Name", "Store", "Work", "Other"}),
#"Grouped Rows" = Table.Group(#"Removed Other Columns", {"Date", "Full Name", "Store"}, {{"Sum Work", each List.Sum([Work]), type number}, {"Sum Other", each List.Sum([Other]), type number}}),
#"Added Conditional Column" = Table.AddColumn(#"Grouped Rows", "Location", each if [Sum Work] = [Sum Other] then "Off Site" else "On Site"),
Custom1 = Table.NestedJoin(#"Changed Type",{"Date", "Full Name", "Store"},#"Added Conditional Column",{"Date", "Full Name", "Store"},"Custom"),
#"Expanded Custom" = Table.ExpandTableColumn(Custom1, "Custom", {"Location"}, {"Location"})
in
#"Expanded Custom"

View solution in original post

2 REPLIES 2
MODUser
Frequent Visitor

Work, thank you! Had to adjust as the store could be 1 - 3 stores, so I removed "Store" as and where applicable. Thanks Again!

alannavarro
Resolver I
Resolver I

Hello, did it in a lot of steps, hope it helps.


let
Source = Excel.CurrentWorkbook(){[Name="Table1"]}[Content],
#"Changed Type" = Table.TransformColumnTypes(Source,{{"Date", type date}}),
#"Removed Other Columns" = Table.SelectColumns(#"Changed Type",{"Date", "Full Name", "Store", "Work", "Other"}),
#"Grouped Rows" = Table.Group(#"Removed Other Columns", {"Date", "Full Name", "Store"}, {{"Sum Work", each List.Sum([Work]), type number}, {"Sum Other", each List.Sum([Other]), type number}}),
#"Added Conditional Column" = Table.AddColumn(#"Grouped Rows", "Location", each if [Sum Work] = [Sum Other] then "Off Site" else "On Site"),
Custom1 = Table.NestedJoin(#"Changed Type",{"Date", "Full Name", "Store"},#"Added Conditional Column",{"Date", "Full Name", "Store"},"Custom"),
#"Expanded Custom" = Table.ExpandTableColumn(Custom1, "Custom", {"Location"}, {"Location"})
in
#"Expanded Custom"

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.

Top Solution Authors
Top Kudoed Authors