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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
Syndicate_Admin
Administrator
Administrator

EDATE + CALCULATE

Good

I have a Logistic (fact_Excel_Logistic) table that has the following columns:

Date. Date on which the order goes out.

Final Restriction. Number of years of restriction depending on whether it is one country or another.

Type. Column with transport type. I have two types: Temporary or Definitive

What I intend to do is take the Date column of the Logistic table and add the number of years depending on the country so that it gives me an end date. For example if I have an order date on 02-03-21 and the number of years in that country is 4 years, give me an end date 02-03-25.

In addition to that I want to do it filtering only for those orders that the Type = Temporary.

I propose it in two steps:

  1. I ultilizo the EDATE to get the final date.
  2. I use CALCULATE to be able to filter

That is what I am proposing. But it backs up for me:

TemploraryRestriction =

VAR _EndDate= MINX(

'fact_Excel_Logistic',

EDATE('fact_Excel_Logistic'[Date],MONTH('fact_Excel_Logistic'[Final Restriction])*12))

VAR TemporaryFilter= CALCULATE(

_EndDate,'fact_Excel_Logistic'[Type]="Temporary")

Return

TemporaryFilter

In addition, I would like Type=Temporary to execute the operation, and for Type= Definitive to return "Not applicable".

Thank you very much for your help.

Best regards.

2 REPLIES 2
Syndicate_Admin
Administrator
Administrator

Good

Thanks for the answer, but I always try to avoid calculated columns and do it through measurements.

I have thought about this solution.

Do you see problems or have any improvement?

TemploraryRestriction =

WHERE _EndDate= MINX(

'fact_Excel_Logistic',

EDATE('fact_Excel_Tráfico'[Date],'fact_Excel_Logistic'[Final Restriction]*12))

WHERE TemporaryFilter= CALCULATE(

_EndDate,'fact_Excel_Logistic'[Type]="Temporary")

WHERE TypeAd=

CALCULATE(

.MAX('fact_Excel_Logistic'[Type]),

ALL(dim_TimeTable)

)

Return

SWITCH(

TRUE()

,TypeAd="Temporary",TemporaryFilter

,TypeAd="Definitive","ON"

," ")

You'll tell me.

Thanks a lot.

v-cgao-msft
Community Support
Community Support

Hi,

I created a calculated column, is this your expected output?

TemploraryRestriction = 
IF (
    'fact_Excel_Logistic'[Type] = "Temporary",
    EDATE (
        'fact_Excel_Logistic'[Date],
        'fact_Excel_Logistic'[Final Restriction] * 12
    )
)

vcgaomsft_0-1694586768922.png
If this doesn't work, could you please give the expected output? Thanks.

Best Regards,
Gao

Community Support Team

 

If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!

How to get your questions answered quickly --  How to provide sample data in the Power BI Forum

Helpful resources

Announcements
RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.