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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
Anonymous
Not applicable

Need help on conditional format previous week sales

Hi, I want this table to show icons (arrows up, down or equal) if the previous week sales is higher, lower or equal to the sales of the week of that column. Eg: Sales of "boller" in week 43 is higher than in week 42, thus must the arrow point upwards. The other way around for sales of Brød in week 43, that should be downward.

 

This is my DAX code: 

Icon =
VAR _val =
CALCULATE (
SUM ( Datagrunnlag[Antall solgt]))
-
CALCULATE (
SUM (Datagrunnlag[Antall solgt]),Datagrunnlag,Datagrunnlag[Week number]-1)
 
RETURN
SWITCH ( TRUE (),
_val < 0, -1,
_val = 0, 0,
_val > 0, 1 )
then i use conditional formatting based on rule "Icon"
e

Henristu_0-1605274398577.png

 

2 REPLIES 2
AlB
Community Champion
Community Champion

Hi @Anonymous 

Are you asking how to build the measure or how to display the arrows? Or both?

For the measure try this:

 

Icon =
VAR currentWeekVal_ =
    CALCULATE ( SUM ( Datagrunnlag[Antall solgt] ) )
VAR previousWeekVal_ =
    CALCULATE (
        SUM ( Datagrunnlag[Antall solgt] ),
        FILTER (
            ALL ( Datagrunnlag[Week number] ),
            Datagrunnlag[Week number]
                = MAX ( Datagrunnlag[Week number] ) - 1
        )
    )
VAR _val = currentWeekVal_ - previousWeekVal_
RETURN
    SWITCH ( TRUE (), _val < 0, -1, _val = 0, 0, _val > 0, 1 )

 

 

Please mark the question solved when done and consider giving a thumbs up if posts are helpful.

Contact me privately for support with any larger-scale BI needs, tutoring, etc.

Cheers 

SU18_powerbi_badge

 

kumar27
Advocate V
Advocate V

Let us make it simple .

Use 2 variables.

One for current week and for that use max .

var 2 will have sum with MAX(column name)-1

 

Now use the calculation in  switch statement.

Thanks 

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.