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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now

Reply
4lanR
Frequent Visitor

Difficulty with INSCOPE to display the total result

Hello,

I am having difficulty creating a DAX formula that returns the sum of the differences for each customer within a group. For example, I used the ISINSCOPE formula to perform the calculation with each customer code within the industry segment, but I would like to see the total sum of these differences, which would be 5.49 and not 1.10 in +Δ. With this, I can build an analysis of customer consumption behaviors compared to the same period last year.

VPVA.jpg

here is the code I am using:

+Δ =
VAR
SalesPriorYearIF(
ISINSCOPE(Sales[Site_Code]),
CALCULATE(
       SUM(Sales[Amount]),
PARALLELPERIOD(
        calendar[Date],
               -12,
               MONTH
  )
       ),
         CALCULATE(
        SUM(Sales[Amount]),
        PARALLELPERIOD(
                calendar[Date],
         -12,
         MONTH
         )
              )
)
RETURN
IF(
AND(
(SUM(Sales[Amount]) - SalesPriorYear) > 0,
SalesPriorYear <> BLANK()
),
SUM(Sales[Amount]) - SalesPriorYear
)
1 ACCEPTED SOLUTION
parry2k
Super User
Super User

@4lanR @_AAndrade has given a great solution but not to keep the logic at the multiple places this is what I will do. Just a suggestion.

 

Sum Sales = SUM ( Sales[Amount] )

LY Sales = CALCULATE ( [Sum Sales], SAMEPERIODLASTYEAR ('calendar'[Date] ) )

+ve Diff = 
VAR __Diff = [Sum Sales] - COALESCE ( [LY Sales], 0 )
RETURN IF ( __Diff > 0, __Diff )

+Δ = 
IF(
 ISINSCOPE(Sales[Site_Code]),
    [+ve Diff],
    SUMX(
        SUMMARIZE(
        Sales,
        Sales[Segment],
        Sales[Site_Code]
        ),
        [+ve Diff]
    )
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

View solution in original post

7 REPLIES 7
4lanR
Frequent Visitor

Thank you @parry2k, I managed to solve the problem with your solution. @_AAndrade , your solution also worked, but the summation still considered the differences when there was blank consumption. Nevertheless, thank you very much for the support, everyone 😁

parry2k
Super User
Super User

@4lanR @_AAndrade has given a great solution but not to keep the logic at the multiple places this is what I will do. Just a suggestion.

 

Sum Sales = SUM ( Sales[Amount] )

LY Sales = CALCULATE ( [Sum Sales], SAMEPERIODLASTYEAR ('calendar'[Date] ) )

+ve Diff = 
VAR __Diff = [Sum Sales] - COALESCE ( [LY Sales], 0 )
RETURN IF ( __Diff > 0, __Diff )

+Δ = 
IF(
 ISINSCOPE(Sales[Site_Code]),
    [+ve Diff],
    SUMX(
        SUMMARIZE(
        Sales,
        Sales[Segment],
        Sales[Site_Code]
        ),
        [+ve Diff]
    )
)


Subscribe to the @PowerBIHowTo YT channel for an upcoming video on List and Record functions in Power Query!!

Learn Power BI and Fabric - subscribe to our YT channel - Click here: @PowerBIHowTo

If my solution proved useful, I'd be delighted to receive Kudos. When you put effort into asking a question, it's equally thoughtful to acknowledge and give Kudos to the individual who helped you solve the problem. It's a small gesture that shows appreciation and encouragement! ❤


Did I answer your question? Mark my post as a solution. Proud to be a Super User! Appreciate your Kudos 🙂
Feel free to email me with any of your BI needs.

_AAndrade
Super User
Super User

Hi @4lanR,

I don't understand the first part of your dax code becaus both part of the IF statments seems to me equal.

But using you measure, please try this:

+Δ =
VAR
SalesPriorYear = IF(
ISINSCOPE(Sales[Site_Code]),
CALCULATE(
       SUM(Sales[Amount]),
PARALLELPERIOD(
        calendar[Date],
               -12,
               MONTH
  )
       ),
         CALCULATE(
        SUM(Sales[Amount]),
        PARALLELPERIOD(
                calendar[Date],
         -12,
         MONTH
         )
              )
)
VAR DifMeasure =

IF(
AND(
(SUM(Sales[Amount]) - SalesPriorYear) > 0,
SalesPriorYear <> BLANK()
),
SUM(Sales[Amount]) - SalesPriorYear
)

VAR TotalTab = 
ADDCOLUMNS(
  SUMMARIZE(
           Sales,
           Sales[Segment] 
           ),
  "@Total", DifMeasure 
)
RETURN
IF(
 ISINSCOPE(Sales[Site_Code]),
 Dif,
 SUMX(TotalTab, [@Total])
)




Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Thanks. I tried using this solution, but the expected result was the same; I still couldn't sum all the differences 😢

Could you share a pbix with same data so I can take look?





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Hi @4lanR,

I'm attaching a pbix file with my solution.





Did I answer your question? Mark my post as a solution! Kudos are welcome.

Proud to be a Super User!




Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors