cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
Paz2019
Regular Visitor

Problem with Variation measure

Hello everyone.

I have a Date table called Dim_Date2 and it doesn't connected to my Fact table Sales for others reasons. So, I have to filter date in each measure.

I have the next measure to calculate Sales and Previous Sales:

 

Sales:=CALCULATE(SUM(Fact_Sales[SalesAmount]), FILTER(Fact_Sales,Fact_Sales[SalesDate]>=[MinimumDate]&&Fact_Sales[SalesDate]<=[MaximumDate])) 

Previous Sales:=CALCULATE(Fact_Sales[Sales],DATEADD(Dim_Date2[Date],-[SelectedDays],DAY))
 
MaximumDate:MAX(Dim_Date2[Date]) 

MinimumDate:MIN(Dim_Date2[Date]) 

SelectedDays:CALCULATE(DISTINCTCOUNT(Fact_Sales[KeySalesDate]),FILTER(Fact_Sales,Fact_Sales[SalesDate]>=[MinimumDate]&&Fact_Sales[SalesDate]<=[MaximumDate])) 

 


And the variation is the subtraction of both.

Previous Sales measure works if I select an specific date, but if I select the same date with a Year, month and day... it doesn't work .

Screenshot_9.png

 

I hope you can help me.

 

1 REPLY 1
Anonymous
Not applicable

Hi

You can try:  dateadd(LASTDATE(Dim_Date2[Date]),-1,day)

 Previous Sales = calculate([Sales],dateadd(LASTDATE(Dim_Date2[Date]),-1,day))

 

If I answer your question, please mark my post as a solution, this will also help others.
Please give Kudos for support.

Tomas Santandreu Polanco |Principal Business Intelligence Consultant
www.designmind.com

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors