Forum Discussion
New Card Visual - Editing interactions for a single card
- 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 PrevStoreSecond 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.
If I understand correctly the problem is that this measure
Previous Month Best Store =
VAR PrevStore =
CALCULATE (
FIRSTNONBLANK (
TOPN (
1,
VALUES ( 'Store'[store_location] ),
[Total Revenue], DESC
),
1
),
DATEADD ( 'Date'[Date], -1, MONTH ),
REMOVEFILTERS ( 'Store'[store_location] )
)
RETURN
IF ( ISBLANK(PrevStore), BLANK(), PrevStore )
returns to you a store with no sales (Astoria)
If that is correct,
Previous Month Best Store =
VAR PrevStore =
CALCULATE (
FIRSTNONBLANK (
FILTER(
ADDCOLUMNS (
TOPN (
1,
VALUES ( 'Store'[store_location] ),
[Total Revenue], DESC
),
"@SalesVal", [Total Revenue]
),
[@SalesVal] > 0
),
1
),
DATEADD ( 'Date'[Date], -1, MONTH ),
REMOVEFILTERS ( 'Store'[store_location] )
)
RETURN
IF ( ISBLANK(PrevStore), BLANK(), PrevStore )
Hope this helps getting a blank value for the prior month best store
If this helped, please consider giving kudos and mark as a solution
me in replies or I'll lose your thread
Want to check your DAX skills? Answer my biweekly DAX challenges on the kubisco Linkedin page
Consider voting this Power BI idea
Francesco Bergamaschi
MBA, M.Eng, M.Econ, Professor of BI
- Anonymous007299 months ago
Helper I
Hi FBergamaschi, thank you so much for taking the time out to assist me. I greatly appreciate it! Unfortunately this solution didn't work for me. But, the one Ahmed-Elfeel suggested worked perfectly.