Forum Discussion

VMP's avatar
VMP
Frequent Visitor
2 years ago
Solved

YTD Calculation without Date table

Hello,   I have data which have only Period column, e.g 2024-P01, 2024-P02...., no sequential date. My dashboard has Period slicer. I have tired both below options to calculate YTD though I am gett...
  • Anonymous's avatar
    Anonymous
    2 years ago

    Hi VMP ,

     

    Thanks for the reply from aduguid / Greg_Deckler .

     

    Create a calculated column in each of the two tables, convert the text format Period to an integer format Period for easy comparison.

    Period Num =
    VALUE(LEFT('Inventory'[Period], 4)) * 100 + VALUE(RIGHT('Inventory'[Period], 2))
    
    Period No =
    VALUE(LEFT('Period A'[Period], 4)) * 100 + VALUE(RIGHT('Period A'[Period], 2))

     

    The two tables need to be disconnected.

     

    Create a measure to calculate YTD:

    Cost YTD =
    VAR SelectedNo = SELECTEDVALUE('Period A'[Period No])
    RETURN
    CALCULATE(
    SUM(Inventory[Total Cost]),
    FILTER(
    ALL('Inventory'[Period Num]),
    'Inventory'[Period Num] <= SelectedNo
    )
    )

     

    The final page visual effect is as shown below:

     

    If you have any other questions please feel free to contact me.

     

    The pbix file is attached.

     

    Best Regards,
    Yang
    Community Support Team

     

    If there is any post helps, then please consider Accept it as the solution  to help the other members find it more quickly.
    If I misunderstand your needs or you still have problems on it, please feel free to let us know. Thanks a lot!