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

July 7 - July 17 | Round 2 of the Power BI Dataviz World Championships. Don't miss your chance! Learn more

Reply
ak77
Post Patron
Post Patron

DAX Help

Hi All,

 

I need help with the DAX formula for the below scenario.. please check

 

Below is the table i am using and MTD ,QTD and YTD are measures. the formula used for MTD is as below as i want to calculate the numbers by filter by just benchmark_code column

BM_MTD =
CALCULATE(
    [Total BM Return],
    DATESMTD('Date Table'[_Date]),ALLEXCEPT ( Broad_Market_Indices_Data,Broad_Market_Indices_Data[benchmark_code] )
)

ak77_0-1699406610074.png

Now the user wants to remove the Code Column and calculate all the measures.. when i remove the code column from the Table the  values are getting wrong.is there a way to remove Code Column from the table and still use the same formula as mentioned above? please help 

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@ak77 , Try this version

 

BM_MTD =
CALCULATE(
[Total BM Return],
DATESMTD('Date Table'[_Date]),filter ( all(Broad_Market_Indices_Data),Broad_Market_Indices_Data[benchmark_code] = max(Broad_Market_Indices_Data[benchmark_code]) )
)

 

 

and is benchmark_code is same as the code; try to have that in a separate dimension and use that in code

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Date date should be marked as date table and join should single direction

 

Make sure this code alone is working

 

BM_MTD =
CALCULATE(
[Total BM Return],
DATESMTD('Date Table'[_Date]) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

View solution in original post

4 REPLIES 4
Ashish_Mathur
Super User
Super User

Hi,

In your measure, replace benchmark_code with benchmark_name.


Regards,
Ashish Mathur
http://www.ashishmathur.com
https://www.linkedin.com/in/excelenthusiasts/

@Ashish_Mathur , Thanks for reply ...i want to calculate using code as name is changing for a particular code after a certain period

 

@amitchandak , Thanks for reply, i am trying ur DAX.wil get back to u

 

Thanks again guys

amitchandak
Super User
Super User

@ak77 , Try this version

 

BM_MTD =
CALCULATE(
[Total BM Return],
DATESMTD('Date Table'[_Date]),filter ( all(Broad_Market_Indices_Data),Broad_Market_Indices_Data[benchmark_code] = max(Broad_Market_Indices_Data[benchmark_code]) )
)

 

 

and is benchmark_code is same as the code; try to have that in a separate dimension and use that in code

 

If this does not help
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

 

Date date should be marked as date table and join should single direction

 

Make sure this code alone is working

 

BM_MTD =
CALCULATE(
[Total BM Return],
DATESMTD('Date Table'[_Date]) )

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Thanks @amitchandak , ur reply worked for me. Thanks 

Helpful resources

Announcements
FabCon and SQLCon Barcelona 2026

FabCon & SQLCon – Barcelona 2026

Join us in Barcelona for FabCon and SQLCon, the Fabric, Power BI, SQL, and AI community event. Save €200 with code FABCMTY200.

60 days of Data Days Carousel

Data Days 2026

Join Fabric Data Days 2026: 60 days of free live/on-demand sessions, challenges, study groups, and certification opportunities.

Power BI DataViz World Championships carousel

Power BI DataViz World Championships - June 2026

A new Power BI DataViz World Championship is coming this June! Don't miss out on submitting your entry.