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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch now

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.

Top Solution Authors