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

Next up in the FabCon + SQLCon recap series: The roadmap for Microsoft SQL and Maximizing Developer experiences in Fabric. All sessions are available on-demand after the live show. Register now

Reply
Nanjita
Frequent Visitor

Calculating variance per location

Hi, I'm fairly new to Power BI and DAX. I would very much appreciate the help. Thanks in advance.

 

I have a database with accidents and incidents, the location where they happened, the month they happened and the reference. I’m trying to calculate the variance in the same way as I do in excel. In excel the grand total is the number of times a location is counted in the data in the current month. A separate tab counts the location listed in the previous month. Variance is then calculated by subtracting the previous month from the current month.

 

In PowerBI the location is counted by counting the reference (string value) per location. I’ve tried to make measures for the count per location in the current month and the previous month and another measure for the difference (variance). Unfortunately it takes the total and shows that for every location.

 

I’ve made the following measures:

Count_reference = COUNT('Data'[Reference])

 

current month = CALCULATE ([Count_reference], FILTER (ALL ('Data'), 'Data'[Event Month]= DATE (YEAR (TODAY ()), MONTH (TODAY ())-2, 1)))

 

previous month = CALCULATE ([Count_reference], FILTER (ALL ('Data'), 'Data'[Event Month]= DATE (YEAR (TODAY ()), MONTH (TODAY ())-3, 1)))

 

monthly variance = [current month]-[previous month]

 

Is there a way to calculate the variance per location in this specific set of circumstances?

 

Please find the excel file here:

https://www.dropbox.com/scl/fi/o6928pmqfqahcc1lthc3z/Accidents-and-Incidents-Dummy.xlsx?dl=0&rlkey=6...

1 ACCEPTED SOLUTION

@Nanjita 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




View solution in original post

6 REPLIES 6
ryan_mayu
Super User
Super User

@Nanjita 

which sheet do you want to recreate in PBI?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




The sheet called "Month Sub Type by Service", specifically column N the Variance prev month

Nanjita
Frequent Visitor

The variance is found in the excel file in the tab called "Month Sub Type by Service" column N.

@Nanjita 

pls see the attachment below





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Amazing, thank you so much!

you are welcome





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Helpful resources

Announcements
New to Fabric survey Carousel

New to Fabric Survey

If you have recently started exploring Fabric, we'd love to hear how it's going. Your feedback can help with product improvements.

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.

March Power BI Update Carousel

Power BI Community Update - March 2026

Check out the March 2026 Power BI update to learn about new features.