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
smstrickland
Helper I
Helper I

Help with DAX measure

My organization has two time entry systems. I have created a matrix that shows the total number of hours entered into each system, per project, that can be filtered by employee and pay period. A sample result is below, with the Comparison column being a measure that subtracts the time in System 2 from the time in System 1. (Project Name, System 1 time, and System 2 time are all in different tables connected through a series of relationships.)

 

 Pay Period Ending 1/31/2020
Project NameSyst 1 TimeSys 2 TimeComparison
PROJ 15.55.50
PROJ 25.55.50
PROJ 312.2512.250
PrROJ 413.7513.750
PROJ 50.50.50
PROJ 63.53.50
PROJ 718180
PROJ 80.5 -0.5
PROJ 97.580.5
PROJ 10550
PROJ 11330
Total75750

 

In another matrix, I want to show, by employee, whether or not the time entered into both systems match. I have been able to create a measure that will compare the total hours in each system, filtered by pay period, but that result is not what I want since, as can be seen in the above sample data, the total number of hours in each system does match, but the number of hours per project does not. I want to be able to show that this person's time does not match in both systems without having to include the project rows in the second matrix.

 

Is there a way to do this? I have thought that I might need to use 'group by' but I just don't know enough about DAX to know if that is correct or how to write such a measure if it is. Any help would be appreciated.  --Shauna

 

BTW - I am not able to provide .pbix files due to company policy, but I'm happy to provide additional information about the data sets if needed.

1 ACCEPTED SOLUTION

In that case, then somthing like this should work:

 

Measure =
  VAR __Table =
    SUMMARIZE(
      'Table',[Project],
      "__Comp",[Comparison]
    )
RETURN
  IF(COUNTROWS(FILTER(__Table,[Comparison] <> 0)) = 0,"Good","Bad")

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

7 REPLIES 7
Greg_Deckler
Super User
Super User

Well, it is very difficult to be specific because you talk about a person and wanting to display by person but there is no person in the sample data and no information about if the person name is in the table or another related table, how those tables are related, etc.

 

So, I can provide a general solution. Use SUMMARIZE or GROUPBY to summarize by person and by project and add in your Comparison measure/column. Filter that such that you filter out any 0's for Comparison. Do a COUNTROWS. If COUNTROWS is 0/BLANK then no discrepencies. Otherwise, discrepencies.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Sorry about the confusion/vagueness within my first post. I have a table that contains Projects, a table that contains Employees, a table that contains time from System 1, a table that contains time for System 2, and a table that contains the Pay Period Dates as well as a number of other tables that provide additional information that help to create all of the relationships between the tables. Employee is not included in the sample data matrix because it is not a field in that matrix. Instead, I have used a slicer to allow the user to filter by Employee.

 

I hope that helps.  --Shauna

In that case, then somthing like this should work:

 

Measure =
  VAR __Table =
    SUMMARIZE(
      'Table',[Project],
      "__Comp",[Comparison]
    )
RETURN
  IF(COUNTROWS(FILTER(__Table,[Comparison] <> 0)) = 0,"Good","Bad")

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Thank you so much! This worked (and I marked it as a solution), but I would prefer for blanks to be considered "Bad." How should I change the IF statement to accomplish that?

@smstrickland - Great! Not sure I follow though on your follow-up question.

 

Measure =
  VAR __Table =
    SUMMARIZE(
      'Table',[Project],
      "__Comp",[Comparison]
    )
RETURN
  IF(COUNTROWS(FILTER(__Table,[Comparison] <> 0)) = 0,"Bad","Good")

?


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler Never mind the last question, and thank you again for your help.  --Shauna

No problem! 🙂

@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.