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

Group data by before a date

I am trying to make a graph that shows all the devices that have appeared in the graph before a specific date.

 

For example, my original data is: with the first column as date and second as device name

7/21/2021b1
7/21/2021b2
7/22/2021b1
7/22/2021b3
7/23/2021b4
7/24/2021b1
7/24/2021b2

 

For 7/21/2021, the result should be b1, b2;

for 7/22/2021 the result should be b1, b2, b3. Although there is no record for b2 on 7/22/2021, there is a record for it on the previous day so we also include it here;

for 7/23/2021 the result should be b1, b2, b3,b4;

for 7/24/2021 the result should also be b1, b2, b3,b4.

 

Thank you so much for your help!

1 ACCEPTED SOLUTION
Greg_Deckler
Super User
Super User

@martcatnip Not exactly certain how you want the return data, but this is essentially a Complex Selector, The Complex Selector - Microsoft Power BI Community

 

Maybe something like:

Measure = 
  VAR __SelectedDate = MAX('Table'[Date])
  VAR __Table = FILTER(ALL('Table'),[Date]<=__SelectedDate)
  VAR __Devices = DISTINCT(__Table,[Device])
RETURN
  CONCATENATEX(__Devices,[Device],",")

@ 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

1 REPLY 1
Greg_Deckler
Super User
Super User

@martcatnip Not exactly certain how you want the return data, but this is essentially a Complex Selector, The Complex Selector - Microsoft Power BI Community

 

Maybe something like:

Measure = 
  VAR __SelectedDate = MAX('Table'[Date])
  VAR __Table = FILTER(ALL('Table'),[Date]<=__SelectedDate)
  VAR __Devices = DISTINCT(__Table,[Device])
RETURN
  CONCATENATEX(__Devices,[Device],",")

@ 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.