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
Anonymous
Not applicable

Need Help: Power BI filter with group by

Hi All,

 

I have an unique screnario which i am at wits end trying to resolve. The data looks like below, where each user has number of hours worked for a week. The hours can have any value greater than 0.

usernamehoursstart weekend week
A407/4/20217/10/2021
A367/11/20217/17/2021
A347/18/20217/24/2021
A307/25/20218/1/2021
B507/4/20217/10/2021
B207/11/20217/17/2021
B207/18/20217/24/2021
B207/25/20218/1/2021
C287/4/20217/10/2021
C327/11/20217/17/2021
C447/18/20217/24/2021
C507/25/20218/1/2021

 

I want to add a dropdown to the visual where the user can select a value for number of hours(5,10,20, 30,35 etc).

If the latest hour value(based on dates) is greater than the value selected, ignore that user.

If the latest hour value(based on dates) is less than value selected, select user and get end date of period where its higher. 

For e.g. if the user selects 35, the output will be :

 end of week
A7/17/2021
B7/10/2021

In the above, 

A367/11/20217/17/2021

 row is higher than the 35 hour, so select that row and not the row above.

For B, a similar logic applies.

 

Please let me know if you have any ideas how to proceed with this. Thanks in advance.

1 ACCEPTED SOLUTION
mahoneypat
Employee
Employee

Here is a measure expression that works with your username column in a  table visual, and a disconnected table with GENERATESERIES for the slicer.with

 

SlicerHours = GENERATESERIES(20,50,5)
 
mahoneypat_0-1625872902854.png

 

Latest Week Over Limit =
VAR slicervalue =
    MAX ( SlicerHours[Value] )
VAR latesthours =
    LASTNONBLANKVALUE ( Hours[end week], CALCULATE ( MAX ( Hours[hours] ) ) )
VAR latestweekabove =
    CALCULATE ( MAX ( Hours[end week] ), Hours[hours] >= slicervalue )
RETURN
    IF ( latesthours >= slicervalueBLANK ()latestweekabove )

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


View solution in original post

2 REPLIES 2
mahoneypat
Employee
Employee

Here is a measure expression that works with your username column in a  table visual, and a disconnected table with GENERATESERIES for the slicer.with

 

SlicerHours = GENERATESERIES(20,50,5)
 
mahoneypat_0-1625872902854.png

 

Latest Week Over Limit =
VAR slicervalue =
    MAX ( SlicerHours[Value] )
VAR latesthours =
    LASTNONBLANKVALUE ( Hours[end week], CALCULATE ( MAX ( Hours[hours] ) ) )
VAR latestweekabove =
    CALCULATE ( MAX ( Hours[end week] ), Hours[hours] >= slicervalue )
RETURN
    IF ( latesthours >= slicervalueBLANK ()latestweekabove )

 

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


Anonymous
Not applicable

Your are awesome! Much appreciated. 

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.