Forum Discussion
Dynamic Measure that is based on a slicer
- 1 year ago
Hi kimstriebel ,
Thank you for reaching out to the Microsoft Community Forum and for providing the sample data.Based on your scenario, I've outlined a step-by-step approach that I followed to achieve the desired output:
Step1. Created a Date table
DateTable = CALENDAR(MIN(Data[Valued Date]), MAX(Data[Valued Date]))
Then I marked it as a date table and related DateTable[Date] to Data[Valued Date] in the model.Step 2 Added a date slicer
Used DateTable[Date] in the slicer and set it to Between mode so I could pick two specific dates.Step3. Created these measures to capture the selected min and max dates:
SelectedMinDate = MIN('DateTable'[Date])
SelectedMaxDate = MAX('DateTable'[Date])
Step4. Then created these two measures to get the sales per branch on those selected dates:
Sales_MinDate =
VAR _MinDate = [SelectedMinDate]
RETURN
CALCULATE(
SUM(Data[Rpt Sales]),
FILTER(Data, Data[Valued Date] = _MinDate && Data[Branch] = MAX(Data[Branch]))
)Sales_MaxDate =
VAR _MaxDate = [SelectedMaxDate]
RETURN
CALCULATE(
SUM(Data[Rpt Sales]),
FILTER(Data, Data[Valued Date] = _MaxDate && Data[Branch] = MAX(Data[Branch]))
)
Step5. To calculate the change:
Sales_Change = [Sales_MaxDate] - [Sales_MinDate]
Step6. Added a matrix visual:Rows: Branch
Values: Sales_MinDate, Sales_MaxDate, Sales_Change
If this solution helped resolve your query, kindly mark it as Accepted and consider giving a Kudos so it can assist others in the community facing similar issues.
Let me know if you need further assistance!
Thanks & Regards,
Lakshmi Narayana
Hi kimstriebel ,
Thank you for reaching out to the Microsoft Community Forum and for providing the sample data.
Based on your scenario, I've outlined a step-by-step approach that I followed to achieve the desired output:
Step1. Created a Date table
DateTable = CALENDAR(MIN(Data[Valued Date]), MAX(Data[Valued Date]))
Then I marked it as a date table and related DateTable[Date] to Data[Valued Date] in the model.
Step 2 Added a date slicer
Used DateTable[Date] in the slicer and set it to Between mode so I could pick two specific dates.
Step3. Created these measures to capture the selected min and max dates:
SelectedMinDate = MIN('DateTable'[Date])
SelectedMaxDate = MAX('DateTable'[Date])
Step4. Then created these two measures to get the sales per branch on those selected dates:
Sales_MinDate =
VAR _MinDate = [SelectedMinDate]
RETURN
CALCULATE(
SUM(Data[Rpt Sales]),
FILTER(Data, Data[Valued Date] = _MinDate && Data[Branch] = MAX(Data[Branch]))
)
Sales_MaxDate =
VAR _MaxDate = [SelectedMaxDate]
RETURN
CALCULATE(
SUM(Data[Rpt Sales]),
FILTER(Data, Data[Valued Date] = _MaxDate && Data[Branch] = MAX(Data[Branch]))
)
Step5. To calculate the change:
Sales_Change = [Sales_MaxDate] - [Sales_MinDate]
Step6. Added a matrix visual:
Rows: Branch
Values: Sales_MinDate, Sales_MaxDate, Sales_Change
If this solution helped resolve your query, kindly mark it as Accepted and consider giving a Kudos so it can assist others in the community facing similar issues.
Let me know if you need further assistance!
Thanks & Regards,
Lakshmi Narayana
Amazing! Worked perfectly. Thank you so much!