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

The Power BI Data Visualization World Championships is back! It's time to submit your entry. Live now!

Reply
Sachy123
Helper V
Helper V

Calculated Column - flag

So my Data is in the following format.

 

 

ReportDateUpdateDateColumn AColumn B
31st December 202020/12/2020 8:00:001080
31st December 202015/12/2020 10:30:008800
31st December 202001/12/2020 8:00:004432
30th November 202029/11/2020 10:30:009099
30th November 202026/11/2020 14:00:334467
30th November 202015/11/2020 15:00:445020

 

I need to add one CALCULATED COLUMN, say FLAG, which becomes 1 when it encounters latest update date at that reporting period

ReportDateUpdateDateColumn AColumn BFlag
31st December 202020/12/2020 8:00:0010801
31st December 202015/12/2020 10:30:0088000
31st December 202001/12/2020 8:00:0044320
30th November 202029/11/2020 10:30:0090991
30th November 202026/11/2020 14:00:3344670
30th November 202015/11/2020 15:00:4450200

 

1 ACCEPTED SOLUTION
mahoneypat
Microsoft Employee
Microsoft Employee

You can convert that expression to a measure and use it in a visual with the UpdateDate and ReportDate columns as follows

 

NewFlagColumn =
VAR vMaxThisPeriod =
    CALCULATE (
        MAX ( Report[UpdateDate] ),
        ALLEXCEPT (
            Report,
            Report[ReportDate]
        )
    )
RETURN
    IF (
        MIN(Report[UpdateDate]) = vMaxThisPeriod,
        1,
        0
    )

 

Regards,

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

3 REPLIES 3
mahoneypat
Microsoft Employee
Microsoft Employee

You can convert that expression to a measure and use it in a visual with the UpdateDate and ReportDate columns as follows

 

NewFlagColumn =
VAR vMaxThisPeriod =
    CALCULATE (
        MAX ( Report[UpdateDate] ),
        ALLEXCEPT (
            Report,
            Report[ReportDate]
        )
    )
RETURN
    IF (
        MIN(Report[UpdateDate]) = vMaxThisPeriod,
        1,
        0
    )

 

Regards,

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


mahoneypat
Microsoft Employee
Microsoft Employee

Here is a column expression that should work.  Replace Report with your actual table name.  Note that I had to convert your first two columns to Date and Date/Time.

 

NewFlagColumn =
VAR vMaxThisPeriod =
    CALCULATE (
        MAX ( Report[UpdateDate] ),
        ALLEXCEPT (
            Report,
            Report[ReportDate]
        )
    )
RETURN
    IF (
        Report[UpdateDate] = vMaxThisPeriod,
        1,
        0
    )

 

Regards,

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


strangely, it gives me a red line under the Calculate function and the tool tip is "CALCULATE is not a function" 

BTW, the table is a result of DIRECT QUERY

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! It's time to submit your entry.

January Power BI Update Carousel

Power BI Monthly Update - January 2026

Check out the January 2026 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.