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

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes! Register now.

Reply
Gopal_PV
Helper III
Helper III

How Write Dax code to show trend Line on Year , Quarter , Month , Day Drill Downs

Hi Friends,

Can you please help me in this. 

dax.png

2 REPLIES 2
Anonymous
Not applicable

Hi @Gopal_PV ,

Based on my testing, please try the following methods:

1.Create the sample table.

vjiewumsft_0-1711704686231.png

2.Create the measure to calculate month.

 

MonthLine = 
VAR day_ = CALCULATE(SUM('Table test'[Product sales]), FILTER(ALLEXCEPT('Table test', 'Table test'[Month]), MIN('Table test'[Month])))
VAR al_sum = SUM('Table test'[Product sales])
VAR result = DIVIDE(al_sum, day_)
RETURN
result

 

 

3.Create the measure to calculate Year.

 

YearLine = 
VAR day_ = CALCULATE(SUM('Table test'[Product sales]), FILTER(ALLEXCEPT('Table test', 'Table test'[Year]), MIN('Table test'[Year])))
VAR al_sum = SUM('Table test'[Product sales])
VAR result = DIVIDE(al_sum, day_)
RETURN
//FORMAT(result, "0.0%")
result

 

 

4.Drag the measure into the line and column chart visual. Select the percentage.

vjiewumsft_1-1711704765052.png

vjiewumsft_2-1711705651193.png

 

5.The result is shown below.

vjiewumsft_0-1711705574936.pngvjiewumsft_1-1711705602735.png

 

 

 

Best Regards,

Wisdom Wu

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Hi @v-jiewu-msft 

Thank you for your reply. I want to see Year/ Quarter/Month/ Day value on Visual. where i will drill down to . Based drill it should show the Trendline percentage.

 

Calender_Model.png

 

Trend % Line =
VAR CVal = Master[ProductCount]
VAR PVal =
SWITCH (
TRUE (),
ISINSCOPE ( Master[dt]),
CALCULATE (
Master[ProductCount],
DATEADD ( Master[dt], -1, DAY)
),

ISINSCOPE ( Master[fscl_Mnth_nbr]),
CALCULATE (
Master[ProductCount],
PARALLELPERIOD ( Master[dt], -1, MONTH ))
,
ISINSCOPE ( Master[fscl_qtr_lbl]),
CALCULATE (
Master[ProductCount],
PARALLELPERIOD ( Master[dt], -1, QUARTER )
),
ISINSCOPE ( Master[fscl_yr_nbr]),
CALCULATE (
Master[ProductCount],
PARALLELPERIOD ( Master[dt], -1, YEAR )
)
)
RETURN
DIVIDE ( CVal - PVal, PVal )

Helpful resources

Announcements
September Power BI Update Carousel

Power BI Monthly Update - September 2025

Check out the September 2025 Power BI update to learn about new features.

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.