cancel
Showing results for 
Search instead for 
Did you mean: 

Fabric is Generally Available. Browse Fabric Presentations. Work towards your Fabric certification with the Cloud Skills Challenge.

Reply
MarioA
New Member

Simple Like for like analysis

Hello Guys,

 

I am faced with a classic like for like problem. 

 

I have a set of stores data, and would like to create a column where I can flag which store is "like for like", which one has been closed, which one has been opened from one year to another. See below example.

 

In my simple mind it is something like: IF StoreID is found in both years then Like for Like; if StoreID is found only in 2021 is Closed; if StoreID only in 2022 is new.

 

Only thing... I cannot translate this in DAX. 

 

Thanks a lot for your help!

 

Mario

 

YearStoreIDSalesStatus
2021Store_110Like for like
2022Store_110Like for like
2022Store_210Open
2021Store_310Closed

 

 

 

 

1 ACCEPTED SOLUTION
mangaus1111
Solution Sage
Solution Sage

Hi @MarioA ,

try this calculated column

Column = 
VAR MaxYear = MAX('Facts9'[Year])
RETURN
SWITCH(TRUE(),
       COUNTROWS(
               FILTER(
                   'Facts9',
                   'Facts9'[StoreID] = EARLIER('Facts9'[StoreID])
               )) > 1, "Like for like",
       'Facts9'[Year] = MaxYear,"Open",
       'Facts9'[Year] < MaxYear,"Close"      
)

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

3 REPLIES 3
mangaus1111
Solution Sage
Solution Sage

Hi @MarioA ,

try this calculated column

Column = 
VAR MaxYear = MAX('Facts9'[Year])
RETURN
SWITCH(TRUE(),
       COUNTROWS(
               FILTER(
                   'Facts9',
                   'Facts9'[StoreID] = EARLIER('Facts9'[StoreID])
               )) > 1, "Like for like",
       'Facts9'[Year] = MaxYear,"Open",
       'Facts9'[Year] < MaxYear,"Close"      
)

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

mangaus1111
Solution Sage
Solution Sage

Hi @MarioA ,

do you need a measure or a calculated column?

One of the two would work - I am also open to suggestion on wether to utilise one or the other! Thanks a lot for your reply! 

Helpful resources

Announcements
PBI November 2023 Update Carousel

Power BI Monthly Update - November 2023

Check out the November 2023 Power BI update to learn about new features.

Community News

Fabric Community News unified experience

Read the latest Fabric Community announcements, including updates on Power BI, Synapse, Data Factory and Data Activator.

Dashboard in a day with date

Exclusive opportunity for Women!

Join us for a free, hands-on Microsoft workshop led by women trainers for women where you will learn how to build a Dashboard in a Day!

Power BI Fabric Summit Carousel

The largest Power BI and Fabric virtual conference

130+ sessions, 130+ speakers, Product managers, MVPs, and experts. All about Power BI and Fabric. Attend online or watch the recordings.

Top Solution Authors
Top Kudoed Authors