cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
GKJARC
Frequent Visitor

Marking latest date within selected date range

Hi everyone,

In a Power BI report I need to mark Active participants as 1, based on the latest ParticipationDate labeled Green, within the selected date range.
With the date slicer ranging from 1-1-2020 to 31-8-2020, the outcome should be like this:

ID  ParticipationDate   Green/Red   Latest green   Active participant Y/N
1  3-2-2020   Green   12-2-2020   0
1  12-2-2020   Green   12-2-2020   1
1  16-4-2020   Red   12-2-2020   0
2  1-5-2020   Green   1-5-2020   1
2  9-8-2020   Red   1-5-2020   0
2  2-6-2021   Green   1-5-2020   0

 

There are also slicers on the report page for Table1 that need to remain usable:

GKJARC_2-1620316741709.png

Measure used for Latest green:

Latest green =
MAXX(
    FILTER( ALL('Table1'),
        [ID]= MAX([ID]) &&
        Table1[Green/Red] = "Green" &&
        Table1[ParticipationDate] >= MIN('Date'[Date]) && Table1[ParticipationDate] <= MAX('Date'[Date])),
        Table1[ParticipationDate])


Data model in my sample report:

GKJARC_1-1620316703825.png

 

I created this calculated column but it doesn't do the trick, because it ignores the date slicer:

Active participant Y/N =
   IF ( [Latest green] = Table1[ParticipationDate] , 1,
   IF ( ISBLANK(  [Latest green]) , 0
   ,0  ))

What would be the correct way to achieve the desired result? 
1 ACCEPTED SOLUTION
GKJARC
Frequent Visitor

Thank you for your replies, much appreciated!@amitchandak was right and a measure needed to be used:

Active participant Y/N =
     IF ( HASONEVALUE ( Table1 [ID] ),
            IF ( [Latest green] = SUM ( Table1 [ParticipationDate] ) ,1 , 0
            )
     )

The column Table1[ParticipationDate] needs to be set to data type Date or DateTime.

View solution in original post

3 REPLIES 3
GKJARC
Frequent Visitor

Thank you for your replies, much appreciated!@amitchandak was right and a measure needed to be used:

Active participant Y/N =
     IF ( HASONEVALUE ( Table1 [ID] ),
            IF ( [Latest green] = SUM ( Table1 [ParticipationDate] ) ,1 , 0
            )
     )

The column Table1[ParticipationDate] needs to be set to data type Date or DateTime.
v-henryk-mstf
Community Support
Community Support

Hi @GKJARC ,

 

Check whether the ParticipateDate field is the correct date type. After modification, can you get the correct result? I created a similar data model. After importing, the text type is displayed, and the date cannot be judged directly on this field. Is it possible to provide the correct data model (delete sensitive information), I will answer you as soon as possible.


Looking forward to your reply.

Best Regards,
Henry

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

amitchandak
Super User
Super User

@GKJARC , a calculated column will not take the slicer value. You have to create a measure



New Power BI Features
Datamarts: https://youtu.be/8tskWsJTEpg
Field Parameters : https://youtu.be/lqF3Wa1FllE?t=70
Did I answer your question? Mark my post as a solution! Appreciate your Kudos!! !!
Dashboard of My Blogs !! Connect on Linkedin !! Proud to be a Super User!
Want To Learn Power BI
Learn Power BI Beginners !! Advance Power BI Concepts !! Power BI For Tableau User !! Learn Power BI in Hindi !!
!! Subscribe to my youtube Channel !!

Helpful resources

Announcements
June 2022 update 768X460.jpg

Check it out!

Click here to read more about the June 2022 updates!

Power Platform Conf 2022 768x460.jpg

Join us for Microsoft Power Platform Conference

The first Microsoft-sponsored Power Platform Conference is coming in September. 100+ speakers, 150+ sessions, and what's new and next for Power Platform.

Power BI Dev Camp Session 23 768x460.jpg

Check it Out!

Mark your calendars and join us on Thursday, June 30 at 11a PDT for a great session with Ted Pattison!

June 20 episode 7 with aka link 768x460.jpg

The Power BI Community Show

Join us on June 20 at 11 am PDT when Kim Manis shares the latest on Azure Synapse analytics, the Microsoft Intelligent Data Platform, and notable Power BI Updates from Microsoft Build 2022.

Top Solution Authors