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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

Reply
Anonymous
Not applicable

Shorten DAX Formula

Hi Expert

 

I have the following DAX which i write VAR for each M period - how couldi possibly shorten the measure to something managable

VAR M1 =
Calculate([Running Total],
Input[Year] = MonthYear &&

Input[Terms] = "BTMT" &&

Input[BB/FF] = "BB" &&

Input[Time Period No] ] = " &&

Input[BB] = Product &&
Input[M Column] = "M1"

 

VAR M2 =
Calculate([Running Total],
Input[Year] = MonthYear &&

Input[Terms] = "BTMT" &&

Input[BB/FF] = "BB" &&

Input[Time Period No] ] = " &&

Input[BB] = Product &&
Input[M Column] = "M2"

 

Return 

M1+M2

the issue is i am doing this for all period upto M45 hence the DAX has become nearly 400 lines long.

1 ACCEPTED SOLUTION

Hi @Anonymous ,

 

Please try to use the following measure:

 

M1+M2 = Calculate([Running Total],
Input[Year] = MonthYear &&

Input[Terms] = "BTMT" &&

Input[BB/FF] = "BB" &&

Input[Time Period No] ] = " &&

Input[BB] = Product &&
Input[M Column] IN{"M1","M2"})

 

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

 

Best Regards,

Dedmon Dai

View solution in original post

5 REPLIES 5
amitchandak
Super User
Super User

@Anonymous , With your formula, Not sure where calculate is ending

Try this to merge

Input[M Column] in {"M1", "M2", "M3" ,//Add others

}

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here
Anonymous
Not applicable

Hi Amit - this is not working as i the value for each M value has to end up in the correct Month Column...in my matrix table...

Hi @Anonymous ,

 

Please try to use the following measure:

 

M1+M2 = Calculate([Running Total],
Input[Year] = MonthYear &&

Input[Terms] = "BTMT" &&

Input[BB/FF] = "BB" &&

Input[Time Period No] ] = " &&

Input[BB] = Product &&
Input[M Column] IN{"M1","M2"})

 

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

 

Best Regards,

Dedmon Dai

Anonymous
Not applicable

Hi Dedmon....

Can you kindly have a look at this question please.

https://community.powerbi.com/t5/Desktop/Add-values-Via-a-Measure-to-a-Specific-Date/m-p/1765401

@Anonymous ,What are you trying to achieve here. Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Join us as experts from around the world come together to shape the future of data and AI!
At the Microsoft Analytics Community Conference, global leaders and influential voices are stepping up to share their knowledge and help you master the latest in Microsoft Fabric, Copilot, and Purview.
️ November 12th-14th, 2024
 Online Event
Register Here

Helpful resources

Announcements
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.