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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
kgollapinni
Frequent Visitor

Current Year Values are displaying but Prior Year Values are not displaying

Hi All, 

 

I require a line graph that shows the CY and PY values based on the FISCAL year slicer selected on the top. It is showing me only CY values but not the PY values. If I selected the prior year (2023), I can see the PY graph. I want to see the PY values even without 2023 year being selected. 

 

Digital ToGo Avg Ticket PY Chart =
VAR SELECTED_DATE = IF(MAX(DATE_DIM_Fiscal[CALENDAR_DATE])>=TODAY(),TODAY()-1,MAX(DATE_DIM_Fiscal[CALENDAR_DATE]))
VAR END_PERIOD_PY =
LOOKUPVALUE(
    DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY],
    DATE_DIM_Fiscal[CALENDAR_DATE],
    SELECTED_DATE
) -52
VAR START_PERIOD_PY = END_PERIOD_PY - 12
VAR NUMERATOR =
CALCULATE(
    SUMX(
        FILTER(
            FACTTABLE,
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) >= START_PERIOD_PY &&
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) <= END_PERIOD_PY
        ),
        FACTTABLE[NET_SALES]
    ),
    KEEPFILTERS(
        FILTER(
            FACTTABLE,
            RELATED(Order_Dim[ORDER_CHANNEL]) = "Digital" &&
            RELATED(Order_Dim[ORDER_OCCASION]) = "ToGo"
        )
    ),
    REMOVEFILTERS (
        DATE_DIM_Fiscal[FISCAL_YEAR],
        DATE_DIM_Fiscal[QUARTER_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[MONTH_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[FISCAL_WEEK_NUMBER_YEAR]
    )
)
VAR DENOMINATOR =
CALCULATE(
    SUMX(
        FILTER(
            FACTTABLE,
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) >= START_PERIOD &&
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) <= END_PERIOD
        ),
        FACTTABLE[Transaction_Count]
    ),
    KEEPFILTERS(
        FILTER(
            FACTTABLE,
            RELATED(Order_Dim[ORDER_CHANNEL]) = "Digital" &&
            RELATED(Order_Dim[ORDER_OCCASION]) = "ToGo"
        )
    ),
    REMOVEFILTERS (
        DATE_DIM_Fiscal[FISCAL_YEAR],
        DATE_DIM_Fiscal[QUARTER_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[MONTH_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[FISCAL_WEEK_NUMBER_YEAR]
    )
)
RETURN DIVIDE(NUMERATOR, DENOMINATOR)
 
Digital ToGo Avg Ticket CY Chart =
VAR SELECTED_DATE = IF(MAX(DATE_DIM_Fiscal[CALENDAR_DATE])>=TODAY(),TODAY()-1,MAX(DATE_DIM_Fiscal[CALENDAR_DATE]))
VAR END_PERIOD =
LOOKUPVALUE(
    DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY],
    DATE_DIM_Fiscal[CALENDAR_DATE],
    SELECTED_DATE
)
VAR START_PERIOD = END_PERIOD - 12
VAR NUMERATOR =
CALCULATE(
    SUMX(
        FILTER(
            FACTTABLE,
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) >= START_PERIOD &&
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) <= END_PERIOD
        ),
        FACTTABLE[NET_SALES]
    ),
    KEEPFILTERS(
        FILTER(
            FACTTABLE,
            RELATED(Order_Dim[ORDER_CHANNEL]) = "Digital" &&
            RELATED(Order_Dim[ORDER_OCCASION]) = "ToGo"
        )
    ),
    REMOVEFILTERS (
        DATE_DIM_Fiscal[FISCAL_YEAR],
        DATE_DIM_Fiscal[QUARTER_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[MONTH_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[FISCAL_WEEK_NUMBER_YEAR]
    )
)
VAR DENOMINATOR =
CALCULATE(
    SUMX(
        FILTER(
            FACTTABLE,
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) >= START_PERIOD &&
            RELATED(DATE_DIM_Fiscal[FISCAL_YEAR_WEEK_NUMBER_KEY]) <= END_PERIOD
        ),
        FACTTABLE[Transaction_Count]
    ),
    KEEPFILTERS(
        FILTER(
            FACTTABLE,
            RELATED(Order_Dim[ORDER_CHANNEL]) = "Digital" &&
            RELATED(Order_Dim[ORDER_OCCASION]) = "ToGo"
        )
    ),
    REMOVEFILTERS (
        DATE_DIM_Fiscal[FISCAL_YEAR],
        DATE_DIM_Fiscal[QUARTER_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[MONTH_NO_FISCAL_YEAR],
        DATE_DIM_Fiscal[FISCAL_WEEK_NUMBER_YEAR]
    )
)
RETURN DIVIDE(NUMERATOR, DENOMINATOR)

kgollapinni_0-1730869843734.png
If I select 2023 also on the slicer, I get this but just by selecting 2024, I want the below graph to be displayed.
kgollapinni_1-1730869890125.png

 

DATE_DIM_Fiscal = DATE_DIM
DATE_DIM = DATE_DIM_View
With the fact table, they are joined to many relationships with the DATE_KEY.
Even, if I change it to the the Matrix, I cannot view the values. Something is wrong with the DAX. Can someone help me with the issue?

@Ashish_Mathur @lbendlin @rajendraongole1 @Ritaf1983 @amitchandak @Kedar_Pande 

1 ACCEPTED SOLUTION
kgollapinni
Frequent Visitor

I was debugging line-by-line and in the PY somehow the KEEPFILTERS was affected. I removed KEEPFILTERS and used it in FILTERS, which worked for me. 

View solution in original post

2 REPLIES 2
kgollapinni
Frequent Visitor

I was debugging line-by-line and in the PY somehow the KEEPFILTERS was affected. I removed KEEPFILTERS and used it in FILTERS, which worked for me. 

lbendlin
Super User
Super User

Please provide sample data that covers your issue or question completely, in a usable format (not as a screenshot).

Do not include sensitive information. Do not include anything that is unrelated to the issue or question.

Need help uploading data? https://community.fabric.microsoft.com/t5/Community-Blog/How-to-provide-sample-data-in-the-Power-BI-...

Please show the expected outcome based on the sample data you provided.

Want faster answers? https://community.fabric.microsoft.com/t5/Desktop/How-to-Get-Your-Question-Answered-Quickly/m-p/1447...

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

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