Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
2 years ago
Solved

Time Period

Hi Team,   In power bi i need one line and stacked column chart like it should show the previous month data if the date cross 12th of every month or before 12th it should should previous two months...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hello Everyone!!
    Thanks for your responses and your time, really appreciate, but i have solved the issue by my own by using the below mention DAX query. But anyways, really thanks for your support. 

    SelectedMonths =
    VAR CurrentDate = TODAY()
    VAR CurrentDay = DAY(CurrentDate)
    VAR StartDate =
        IF(
            CurrentDay > 12,
            EOMONTH(CurrentDate, -6),
            EOMONTH(CurrentDate, -5)
        )
    VAR EndDate = EOMONTH(CurrentDate, -1)
    VAR EndDate_1 = EOMONTH(CurrentDate, -2)
    RETURN
    IF(CurrentDay>12,
     (CALCULATE(
            SUMX('Measure',[Orders (MUSD)]),
            'Calendar'[Heriearchy] >= StartDate && 'Calendar'[Heriearchy] <= EndDate)),
            CALCULATE(
            SUMX('Measure',[Orders (MUSD)]),
            'Calendar'[Heriearchy] >= StartDate && 'Calendar'[Heriearchy] <= EndDate_1))
     
    Once again thanks for your support.