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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
mbenn
Regular Visitor

Cannot get functions to work correctly

Hopefully after seeing my code and my examples, this question will speak for itself as I am not sure how to word it.

 

So GMDollars LY is simply the Last Year's sales and it works perfectly.  Gross Margin v2 was simply a measure I created from a Calculated column in order to use it in the Sales Last Year Only Measure since I couldn't use a Calculated Column or an Original Column.  (Maybe this is where my problem is stemming from.)  (Also, I do want grand totals of the sums of each column)

 

GMDollars LY = CALCULATE([Gross Margin v2], SAMEPERIODLASTYEAR(rpt_SalesHistoryMAST[GLPostDate].[Date]))
Gross Margin v2 = SUM(rpt_SalesHistoryMAST[Gross Margin])

 

Sales Last Year Only = 
VAR GMD = [GMDollars LY]
VAR GMV2 = [Gross Margin v2]
RETURN
CALCULATE(GMD, FILTER(rpt_SalesHistoryMAST, GMD <> BLANK() && GMV2 = BLANK()))

The first picture below is what I want to happen, and the second picture is what is actually happening with my data.  I have tried a lot of solutions and ended up with Circular Dependency issues or just no calculations whatsoever.  I can get the Sales Last Year Only column to come out correctly but then it will not give me the total sum at the end of the column and that is the one requirement of this project.

 

What I want it to give:

 

ShouldGive.PNG

 

What it actually gives:

 

ActuallyGives.PNG

 

2 REPLIES 2
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi  @mbenn,

 

Could you please mark the proper answers as solutions?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi @mbenn,

 

Can you share the original data, please? We can't check the formulas based on the result.

The solution could be adding one filter condition of Year.

Sales Last Year Only = 
VAR GMD = [GMDollars LY]
VAR GMV2 = [Gross Margin v2]
RETURN
CALCULATE(GMD, FILTER(rpt_SalesHistoryMAST, GMD <> BLANK() && GMV2 = BLANK()&&[Year] = year(today()) - 1))

Best Regards,

Dale

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

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

Check out the February 2025 Power BI update to learn about new features.

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.

Top Kudoed Authors