Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!View all the Fabric Data Days sessions on demand. View schedule
Dears,
I have used the code below in developing MTD for Sales:
Solved! Go to Solution.
Hi @Maahmohammed ,
If you want to calculate GM%, you can calculate it by dividing the cumulative gross profit by the cumulative sales, here is the DAX I wrote I hope it helps.
GM_MTD =
VAR D=MAX('Table'[Date])
VAR F=DATE(YEAR(D),MONTH(D),1)
VAR B=MIN(DATE(YEAR(D),MONTH(D),DAY(TODAY())),D)
VAR cumulativeprofit=
CALCULATE(
SUM('Table'[Gross_Margin]),
FILTER(ALL('Table'),
'Table'[Date]>=F&&'Table'[Date]<=B))
VAR Cumulativesales= CALCULATE(
SUM('Table'[Sales_5_Total]),
FILTER(ALL('Table'),
'Table'[Date]>=F&&'Table'[Date]<=B
)
)
RETURN
DIVIDE(cumulativeprofit,Cumulativesales,0)
If you have any other questions, check out the pbix file I've uploaded, I'd be incredibly proud to help you out!
Hope it helps!
Best regards,
Community Support Team_ Tom Shen
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Hi @Maahmohammed ,
If you want to calculate GM%, you can calculate it by dividing the cumulative gross profit by the cumulative sales, here is the DAX I wrote I hope it helps.
GM_MTD =
VAR D=MAX('Table'[Date])
VAR F=DATE(YEAR(D),MONTH(D),1)
VAR B=MIN(DATE(YEAR(D),MONTH(D),DAY(TODAY())),D)
VAR cumulativeprofit=
CALCULATE(
SUM('Table'[Gross_Margin]),
FILTER(ALL('Table'),
'Table'[Date]>=F&&'Table'[Date]<=B))
VAR Cumulativesales= CALCULATE(
SUM('Table'[Sales_5_Total]),
FILTER(ALL('Table'),
'Table'[Date]>=F&&'Table'[Date]<=B
)
)
RETURN
DIVIDE(cumulativeprofit,Cumulativesales,0)
If you have any other questions, check out the pbix file I've uploaded, I'd be incredibly proud to help you out!
Hope it helps!
Best regards,
Community Support Team_ Tom Shen
If this post helps then please consider Accept it as the solution to help the other members find it more quickly.
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!