Learn from the best! Meet the four finalists headed to the FINALS of the Power BI Dataviz World Championships! Register now
So my Data is in the following format.
| ReportDate | UpdateDate | Column A | Column B |
| 31st December 2020 | 20/12/2020 8:00:00 | 10 | 80 |
| 31st December 2020 | 15/12/2020 10:30:00 | 88 | 00 |
| 31st December 2020 | 01/12/2020 8:00:00 | 44 | 32 |
| 30th November 2020 | 29/11/2020 10:30:00 | 90 | 99 |
| 30th November 2020 | 26/11/2020 14:00:33 | 44 | 67 |
| 30th November 2020 | 15/11/2020 15:00:44 | 50 | 20 |
I need to add one CALCULATED COLUMN, say FLAG, which becomes 1 when it encounters latest update date at that reporting period
| ReportDate | UpdateDate | Column A | Column B | Flag |
| 31st December 2020 | 20/12/2020 8:00:00 | 10 | 80 | 1 |
| 31st December 2020 | 15/12/2020 10:30:00 | 88 | 00 | 0 |
| 31st December 2020 | 01/12/2020 8:00:00 | 44 | 32 | 0 |
| 30th November 2020 | 29/11/2020 10:30:00 | 90 | 99 | 1 |
| 30th November 2020 | 26/11/2020 14:00:33 | 44 | 67 | 0 |
| 30th November 2020 | 15/11/2020 15:00:44 | 50 | 20 | 0 |
Solved! Go to Solution.
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
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
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
To learn more about Power BI, follow me on Twitter or subscribe on YouTube.
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
To learn more about Power BI, follow me on Twitter or subscribe 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
| User | Count |
|---|---|
| 57 | |
| 43 | |
| 32 | |
| 16 | |
| 13 |
| User | Count |
|---|---|
| 84 | |
| 70 | |
| 37 | |
| 27 | |
| 24 |