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

Earn a 50% discount on the DP-600 certification exam by completing the Fabric 30 Days to Learn It challenge.

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
Employee
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
Employee
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
LearnSurvey

Fabric certifications survey

Certification feedback opportunity for the community.

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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