Forum Discussion

kpct56591's avatar
kpct56591
Frequent Visitor
1 year ago
Solved

Difference between two years showing under both years

Hello,

 

I am trying to have a matrix that displays the YOY difference in quantity shipped. I have a measure that does that, but it displays under both years. How can I remove it from 2023?

I also do not need it to show the difference line if there is no 2023 data for the state.

I attempted to use the Filters on this visual to show only when items are not 0 or not blank, but it hid all 2023 Ship Qty rows.

Here is the measure:

Sum of Ship Qty difference from 2023 = 
VAR __BASELINE_VALUE =
	CALCULATE(
		SUM('ofrordx'[Ship Qty]),
		'ofrordx'[Ship Date].[Year] IN { 2023 }
	)
VAR __MEASURE_VALUE = SUM('ofrordx'[Ship Qty])
RETURN
	IF(NOT ISBLANK(__MEASURE_VALUE), __MEASURE_VALUE - __BASELINE_VALUE)

Many thanks.

  • Hi kpct56591 ,

    Try out this below measure

    ShipQtyDiffFrom2023 =
    VAR ThisYear = SELECTEDVALUE('ofrordx'[Ship Date].[Year])
    VAR CurrentQty = SUM('ofrordx'[Ship Qty])
    VAR BaseQty2023 =
    CALCULATE(
    SUM('ofrordx'[Ship Qty]),
    'ofrordx'[Ship Date].[Year] = 2023
    )
    RETURN
    IF(
    ThisYear > 2023 &&
    NOT ISBLANK(BaseQty2023) &&
    NOT ISBLANK(CurrentQty),
    CurrentQty - BaseQty2023
    )

6 Replies

  • Hi kpct56591,

    AS per understanding, you are trying to calculate YOY difference in a matrix but it is not showing correct results between 2023 and 2024 columns.

    Hope below measure helps you:
    ShipQtyDiffFrom2023 =
    VAR ThisYear = SELECTEDVALUE('ofrordx'[Ship Date].[Year])
    VAR CurrentQty = SUM('ofrordx'[Ship Qty])
    VAR BaseQty2023 =
    CALCULATE(
    SUM('ofrordx'[Ship Qty]),
    'ofrordx'[Ship Date].[Year] = 2023
    )
    RETURN
    IF(
    ThisYear > 2023 && NOT ISBLANK(BaseQty2023),
    CurrentQty - BaseQty2023
    )


    Define Matrix as below:
    Rows - State column
    Columns - Ship Date[Year]
    Values - Ship Qty and ShipQtyDiffFrom2023

    Please let me know if you have further questions. Thanks in advance!

    If this reply helped solve your problem, please consider clicking "Accept as Solution" so others can benefit too. And if you found it useful, a quick "Kudos" is always appreciated — thanks! 

     

    Best Regards, 

    Maruthi 

    LinkedIn - http://www.linkedin.com/in/maruthi-siva-prasad/ 

    X            -  Maruthi Siva Prasad - (@MaruthiSP) / X 

    • kpct56591's avatar
      kpct56591
      Frequent Visitor

      Thank you, Maruthi. Your measure works as does the one I posted. It is still showing under both 2023 and 2024 rows. Shown below. I have tried setting the filter to hide ShipQtyDiffFrom2023 if blank, but it then also hides 2023 Ship Qty. Any thoughts?

       

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi kpct56591 ,

    Try out this below measure

    ShipQtyDiffFrom2023 =
    VAR ThisYear = SELECTEDVALUE('ofrordx'[Ship Date].[Year])
    VAR CurrentQty = SUM('ofrordx'[Ship Qty])
    VAR BaseQty2023 =
    CALCULATE(
    SUM('ofrordx'[Ship Qty]),
    'ofrordx'[Ship Date].[Year] = 2023
    )
    RETURN
    IF(
    ThisYear > 2023 &&
    NOT ISBLANK(BaseQty2023) &&
    NOT ISBLANK(CurrentQty),
    CurrentQty - BaseQty2023
    )

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi kpct56591 ,

    As we haven’t heard back from you, we wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,
    Chaithra.

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi kpct56591 ,

    May I ask if you have gotten this issue resolved?

     

    If it is solved, please mark the helpful reply or share your solution and accept it as solution, it will be helpful for other members of the community who have similar problems as yours to solve it faster.

     

    Regards,
    Chaithra.

  • v-echaithra's avatar
    v-echaithra
    Community Support

    Hi kpct56591 ,

    We wanted to kindly follow up to check if the solution provided for the issue worked? or Let us know if you need any further assistance?
    If our response addressed, please mark it as Accept as solution and click Yes if you found it helpful.

     

    Regards,
    Chaithra.