Forum Discussion

Marshmallow's avatar
Marshmallow
Helper II
1 year ago
Solved

Adding more syntax to the M Query

Hi,  I found the following syntax which is working for me:  let a=#date(Date.Year([Date_Min_Signed]),7,1), b=#date(Date.Year([Date_Min_Signed])+1,6,30) in if [Date_Min_Signed]>=a and [Date_Min_Si...
  • MasonMA's avatar
    1 year ago

    Marshmallow 

     

    Hi, you simply need to append the second year in the format YY, which is always one year after the base year. With adjusted M codes below: 

     

    let
        a = #date(Date.Year([Date_Min_Signed]), 7, 1),
        b = #date(Date.Year([Date_Min_Signed]) + 1, 6, 30),
        fyStartYear = if [Date_Min_Signed] >= a and [Date_Min_Signed] <= b then Date.Year([Date_Min_Signed]) else Date.Year([Date_Min_Signed]) - 1,
        fyEndYear = fyStartYear + 1,
        result = "FY" & Text.End(Text.From(fyStartYear), 2) & "-" & Text.End(Text.From(fyEndYear), 2)
    in
        result

     

  • grazitti_sapna's avatar
    1 year ago

    Hi Marshmallow 

     

    Please try the below M code:

    let
    a = #date(Date.Year([Date_Min_Signed]), 7, 1),
    b = #date(Date.Year([Date_Min_Signed]) + 1, 6, 30),
    fyStartYear = if [Date_Min_Signed] >= a and [Date_Min_Signed] <= b then Date.Year([Date_Min_Signed]) else Date.Year([Date_Min_Signed]) - 1,
    fyEndYear = fyStartYear + 1,
    result = "FY" & Text.End(Text.From(fyStartYear), 2) & "-" & Text.End(Text.From(fyEndYear), 2)
    in
    result


     I hope this solution helps you unlock your Power BI potential! If you found it helpful, click 'Mark as Solution' to guide others toward the answers they need.
     Love the effort? Drop the kudos! Your appreciation fuels community spirit and innovation.
     As a proud SuperUser and Microsoft Partner, we’re here to empower your data journey and the Power BI Community at large.
     Curious to explore more? [Discover here].
    Let’s keep building smarter solutions together!