Forum Discussion
Dax Formula Help - Filters
- Anonymous8 years ago
Hi Harper146,
You can try to use below measure to calculate difference:
Measure = VAR fiscYear = SELECTEDVALUE ( Table1[Fiscal Year ] ) VAR fiscPeriod = SELECTEDVALUE ( Table1[Fiscal Period] ) VAR currProduct = SELECTEDVALUE ( Table1[Product] ) RETURN CALCULATE ( SUM ( Table1[New Customers] ), VALUES ( Table1[Fiscal Year] ), VALUES ( Table1[Fiscal Period] ), VALUES ( Table1[Product] ) ) - CALCULATE ( SUM ( Table1[New Customers] ), FILTER ( ALL ( Table1 ), Table1[Product] IN VALUES ( Table1[Product] ) && Table1[Fiscal Year] = IF ( fiscPeriod = 1, fiscYear - 1, fiscYear ) && Table1[Fiscal Period] = IF ( fiscPeriod = 1, 12, fiscPeriod - 1 ) ) )Regards,
Xiaoxin Sheng
Hi Harper146,
SELECTEDVALUE and HASONEVALUE function only works for single row content, it will return blank if current contents contains or summarize multiple records. So you're formula not works for multiple selection.
BTW, you can use allselected function to get multiple selection values, but it obviously can't use on your original condition. Please provide sample sample data and expected result to help us clarify your requirement.
Regards,
Xiaoxin Sheng
- Harper1468 years agoRegular Visitor
Hi Xiaoxin,
Ah that makes sense, thanks. please see some sample data below:
Fiscal Year Fiscal Period Product New Customers New Turnover Retained customers Retained Turnover 2017 1 Product A 500 10,000 3,000 30,000 2017 1 Product B 200 5,000 2,000 25,000 2017 2 Product A 400 9,000 3,100 32,000 I'm trying to add a colum with the previous periods transactions to the table which will alow me to calculate the Month on Month change.
Thanks
Sam
- Anonymous8 years agoNot applicable
Hi Harper146,
You can try to use below measure to calculate difference:
Measure = VAR fiscYear = SELECTEDVALUE ( Table1[Fiscal Year ] ) VAR fiscPeriod = SELECTEDVALUE ( Table1[Fiscal Period] ) VAR currProduct = SELECTEDVALUE ( Table1[Product] ) RETURN CALCULATE ( SUM ( Table1[New Customers] ), VALUES ( Table1[Fiscal Year] ), VALUES ( Table1[Fiscal Period] ), VALUES ( Table1[Product] ) ) - CALCULATE ( SUM ( Table1[New Customers] ), FILTER ( ALL ( Table1 ), Table1[Product] IN VALUES ( Table1[Product] ) && Table1[Fiscal Year] = IF ( fiscPeriod = 1, fiscYear - 1, fiscYear ) && Table1[Fiscal Period] = IF ( fiscPeriod = 1, 12, fiscPeriod - 1 ) ) )Regards,
Xiaoxin Sheng
- Harper1468 years agoRegular Visitor
Thanks Xiaoxin, works perfectly