Forum Discussion

Anonymous00729's avatar
9 months ago
Solved

New Card Visual - Editing interactions for a single card

Hi all, I have another question. I’m using a new card visual where I want to display the Best Performing Store. If there was a change in the best performing store, I want to show that in my referenc...
  • Ahmed-Elfeel's avatar
    9 months ago

    Hi Anonymous00729,

    I hope you are doing well today ☺️❤️

     

    So you have 3 Issues need to be Solved:

    • Blank Previous Month in January
    • Store Location Slicer Affecting Best Store Calculation
    • Changing Indicator Showing Incorrect Message

    First Issue

    The Issue is that your Previous Month Best Store measure doesnt properly handle the case when there is no data for the previous month. Here is the corrected measure:

    Previous Month Best Store =
    VAR CurrentMonthStart = MIN('Date'[Date])  // First day of selected month
    VAR PreviousMonthStart = DATE(YEAR(CurrentMonthStart), MONTH(CurrentMonthStart) - 1, 1)
    VAR PreviousMonthEnd = EOMONTH(CurrentMonthStart, -1)
    
    VAR HasPreviousMonthData = 
        NOT ISBLANK(
            CALCULATE(
                [Total Revenue],
                'Date'[Date] >= PreviousMonthStart,
                'Date'[Date] <= PreviousMonthEnd,
                REMOVEFILTERS('Store'[store_location])
            )
        )
    
    VAR PrevStore =
        IF(
            HasPreviousMonthData,
            CALCULATE(
                FIRSTNONBLANK(
                    TOPN(
                        1,
                        VALUES('Store'[store_location]),
                        [Total Revenue], DESC
                    ),
                    1
                ),
                'Date'[Date] >= PreviousMonthStart,
                'Date'[Date] <= PreviousMonthEnd,
                REMOVEFILTERS('Store'[store_location])
            ),
            BLANK()
        )
    RETURN PrevStore

     

    Second Issue

    You need to modify your Best Performing Store measure to ignore the Store Location slicer:

    Best Performing Store =
    CALCULATE(
        FIRSTNONBLANK(
            TOPN(
                1,
                VALUES('Store'[store_location]),
                [Total Revenue], DESC
            ),
            1
        ),
        REMOVEFILTERS('Store'[store_location])
    )

     

    Final Issue

    • You need to Update Change Indicator Measure too Look like that:
    Best Performing Store ▲ =
    VAR CurrentStore = [Best Performing Store]
    VAR PreviousStore = [Previous Month Best Store]
    RETURN
    SWITCH(
        TRUE(),
        ISBLANK(CurrentStore) && ISBLANK(PreviousStore), BLANK(),
        ISBLANK(CurrentStore) || ISBLANK(PreviousStore), BLANK(),
        CurrentStore = PreviousStore, "No change",
        "Changed from " & PreviousStore & " to " & CurrentStore
    )
    if this post helps, then I would appreciate a thumbs up and mark it as the solution to help the other members find it more quickly.