Kiran Patel
Kiran Patel

Reputation: 65

Need formula to apply in power bi report

enter image description hereI need to add one calculated column in power bi dax. In my excel data there is month end column as shown in table.
Snap of report

As you can see, W05 is last week of 01/2020 (Report Month), so month end is Y, for rest it is N. Same way, W09 is last week of 02/2020 (Report month), month end= Y. rest is N. Can you help me with the formula I can use in power bi to poplulate end month (N or Y)?

Measure outputMeasure output

Upvotes: 1

Views: 73

Answers (1)

mkRabbani
mkRabbani

Reputation: 16908

Create this following measure-

is_last_week = 

var current_report_week = MIN(your_table_name[report week])
var current_minth_max_report_week =
CALCULATE(
    MAX(your_table_name[report week]),
    ALLEXCEPT(your_table_name,your_table_name[report month])
)

RETURN 
IF(
    current_minth_max_report_week = current_report_week,
    "Y",
    "N"
)

For Custom Column, use this below code-

is_last_week = 

var current_report_week = your_table_name[report week]
var current_month_max_report_week =
CALCULATE(
    MAX(your_table_name[report week]),
    ALLEXCEPT(your_table_name,your_table_name[report month])
)

RETURN 
IF(
    current_month_max_report_week = current_report_week,
    "Y",
    "N"
)

Here is the final output-

enter image description here

Upvotes: 1

Related Questions