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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
questionac
New Member

DAX formula / matrix / date

In the matrix table:

  • Rows: Department (selected through the slicer)
  • Columns: Year and month (selected through the slicer)
  • Values: The sales for the selected year and month, as well as the sales for the same month in the previous year.

The DAX function is written as follows, but it does not work correctly. Where should I make corrections?

 

dax
Total Revenue Pre = CALCULATE( SUM('MMSOpptunities'[Current Revenue]), FILTER( ALL('MMSOpptunities'), 'MMSOpptunities'[fiscalyear] = SELECTEDVALUE('MMSOpptunities'[fiscalyear]) - 1 && 'MMSOpptunities'[fiscalquarter] = SELECTEDVALUE('MMSOpptunities'[fiscalquarter]) && 'MMSOpptunities'[fiscalmonth] = SELECTEDVALUE('MMSOpptunities'[fiscalmonth]) ) ) 

slicer
columns:fiscalyear,fiscaquarter,fiscalmonth
values:Current Revenue,Total Revenue Pre
 
 
1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @questionac 

 

I've modeled some data to hopefully fit your situation. You can try the following formula.

 

Total Revenue Pre = 
CALCULATE ( SUM ('MMSOpptunities'[Current Revenue] ),
    FILTER ( ALLEXCEPT( MMSOpptunities,MMSOpptunities[fiscalquarter],MMSOpptunities[fiscalmonth]),
        [fiscalyear] = MAX(  'MMSOpptunities'[fiscalyear] ) - 1

))

 

vzhangtinmsft_0-1734920627044.png

vzhangtinmsft_1-1734920639222.png

Is this the result you expected? If it did not solve your problem, please provide more data.

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Best Regards,

Community Support Team _Charlotte

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

 

View solution in original post

4 REPLIES 4
Anonymous
Not applicable

Hi, @questionac 

 

I've modeled some data to hopefully fit your situation. You can try the following formula.

 

Total Revenue Pre = 
CALCULATE ( SUM ('MMSOpptunities'[Current Revenue] ),
    FILTER ( ALLEXCEPT( MMSOpptunities,MMSOpptunities[fiscalquarter],MMSOpptunities[fiscalmonth]),
        [fiscalyear] = MAX(  'MMSOpptunities'[fiscalyear] ) - 1

))

 

vzhangtinmsft_0-1734920627044.png

vzhangtinmsft_1-1734920639222.png

Is this the result you expected? If it did not solve your problem, please provide more data.

How to provide sample data in the Power BI Forum - Microsoft Fabric Community

 

Best Regards,

Community Support Team _Charlotte

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

 

Kedar_Pande
Super User
Super User

@questionac 

You can try:

Total Revenue Pre =
CALCULATE(
SUM('MMSOpptunities'[Current Revenue]),
FILTER(
ALL('MMSOpptunities'),
'MMSOpptunities'[fiscalyear] = MAX('MMSOpptunities'[fiscalyear]) - 1 &&
'MMSOpptunities'[fiscalmonth] = MAX('MMSOpptunities'[fiscalmonth])
)
)

💌 If this helped, a Kudos 👍 or Solution mark would be great! 🎉
Cheers,
Kedar
Connect on LinkedIn

dharmendars007
Super User
Super User

Hello @questionac , 

 

Please us the below revised measure..


Total Revenue Pre =
CALCULATE(
SUM('MMSOpportunities'[Current Revenue]),
FILTER(
ALL('MMSOpportunities'),
'MMSOpportunities'[fiscalyear] = SELECTEDVALUE('MMSOpportunities'[fiscalyear]) - 1 &&
'MMSOpportunities'[fiscalmonth] = SELECTEDVALUE('MMSOpportunities'[fiscalmonth])))

 

Key Changes:

  1. Removed fiscalquarter from the comparison since fiscalmonth is sufficient to match the period.
  2. Kept ALL to remove filters only on fiscalyear and fiscalmonth while retaining the Department filter.

 

If you find this helpful , please mark it as solution which will be helpful for others and Your Kudos/Likes 👍 are much appreciated!

 

Thank You

Dharmendar S

LinkedIN 

questionac
New Member

data↓(example)

Current RevenueClose Date (Expected Signing or Date Won/Lost/WD)Zanken.TowerZanken.Teamfiscal-datefiscalyearfiscalquarterfiscalmonthmonthnumber
1842022年9月29日アプリ生産管理生産管理_尾道2022/1/29 0:002022Q201月5
1092022年9月29日アプリ生産管理生産管理_尾道2022/1/29 0:002022Q201月5
1422022年9月29日アプリ生産管理生産管理_尾道2022/1/29 0:002022Q201月5
1852022年9月29日アプリ生産管理生産管理_尾道2022/1/29 0:002022Q201月5
1572022年9月29日アプリ生産管理生産管理_尾道2022/1/29 0:002022Q201月5

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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.