Forum Discussion

Yesvanth141's avatar
Yesvanth141
Frequent Visitor
8 years ago
Solved

Power BI/ DAX

Experts,

 

Need to implement below scenarios in PowerBI. Please share your inputs. Thanks in advance.

 

A date column is available in the table/source query

 

MTD
If I select 2018-June,
Current Month 2018-June vs Prior year same month 2017-May
Example 2018-May vs 2017-May

QTD
[2018-Apr]+[2018-May]+[2018-June] versus [2017-Apr]+[2017-May]+[2017-June]

YTD
[2018-Jan] to [2018-June] versus [2017-Jan] to [2017-June]

 

 

 

 

 

 

  • Hi,

     

    Try this

     

    1. Create a Calendar Table
    2. Create a relatiosnhip from the Date column of your base data table to the Date column of your Calendar Table
    3. In the Calendar Table, write the following calculated column formulas: YEAR=YEAR(Calendar[Date]) and Month=FORMAT(Calendar[Date],"mmmm")
    4. Create a slicer for months and another one for Years.  Drag Month and Year from the Calendar Table.  Select any one Year and month
    5. Write these measures

    Revenue=SUM(Data[Sales])

    QTD revenue=CALCULATE([Revenue],DATESQTD(Calendar[Date])

    YTD revenue=CALCULATE([Revenue],DATESYTD(Calendar[Date],"31/12")

     

    Hope this helps.

1 Reply

  • Hi,

     

    Try this

     

    1. Create a Calendar Table
    2. Create a relatiosnhip from the Date column of your base data table to the Date column of your Calendar Table
    3. In the Calendar Table, write the following calculated column formulas: YEAR=YEAR(Calendar[Date]) and Month=FORMAT(Calendar[Date],"mmmm")
    4. Create a slicer for months and another one for Years.  Drag Month and Year from the Calendar Table.  Select any one Year and month
    5. Write these measures

    Revenue=SUM(Data[Sales])

    QTD revenue=CALCULATE([Revenue],DATESQTD(Calendar[Date])

    YTD revenue=CALCULATE([Revenue],DATESYTD(Calendar[Date],"31/12")

     

    Hope this helps.