Join us at FabCon Atlanta from March 16 - 20, 2026, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.
Register now!Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Request now
Hello everyone!
I am having trouble writing a DAX formula in Power BI to calculate Same Store Sales (SSS). My calculation of SSS is (CURRENT_VALUE_ / PREVIOUS_VALUE_) - 1.
The problem is that, when looking at the CLIENT_ID hierarchy in a matrix visual in Power BI, I want the SSS measure to consider only the CURRENT_VALUE_ of the brands that also had sales in PREVIOUS_VALUE_.
For example, in the figure below, I want CLIENT_ID 123456 to show me an SSS of 27% in total, instead of 100%. That is, I want it to consider (140 / 110) - 1, instead of (220 / 110) - 1, as it should only sum the CURRENT_VALUE_ of the brands that also have PREVIOUS_VALUE_ (that is, only the GREEN and PINK brands).
My current DAX formula is as follows:
VAR tempTable = SUMMARIZE(clients, clients[CLIENT_ID], "PER_ATUAL", [CURRENT_VALUE_] ,"PER_ANTER", [PREVIOUS_VALUE_])
VAR currentValue = SUMX(FILTER(tempTable, NOT ISBLANK([PER_ATUAL]) && NOT ISBLANK([PER_ANTER])), [PER_ATUAL])
VAR previousValue = SUMX(FILTER(tempTable, NOT ISBLANK([PER_ATUAL]) && NOT ISBLANK([PER_ANTER])), [PER_ANTER])
RETURN
IF(DIVIDE(currentValue, previousValue, BLANK()) -1 = -1 ,
BLANK(),
DIVIDE(currentValue, previousValue, BLANK()) -1
)
Any help or tips?
Solved! Go to Solution.
Hi,
I am not sure how you semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
Current sales: =
SUM( sales[sales] )
Previous sales: =
CALCULATE (
[Current sales:],
OFFSET ( -1, ALL ( 'year'[year] ), ORDERBY ( 'year'[year], ASC ) )
)
Expected result measure: =
VAR _t =
FILTER (
ADDCOLUMNS (
SUMMARIZE ( sales, client[client_id], store[store_id], 'year'[year] ),
"@current", [Current sales:],
"@prev", [Previous sales:]
),
NOT ISBLANK ( [@prev] )
)
VAR _result =
DIVIDE ( SUMX ( _t, [@current] ), SUMX ( _t, [@prev] ) ) - 1
RETURN
IF ( NOT ISBLANK ( [Previous sales:] ), _result )
Hi,
I am not sure how you semantic model looks like, but I tried to create a sample pbix file like below.
Please check the below picture and the attached pbix file.
Current sales: =
SUM( sales[sales] )
Previous sales: =
CALCULATE (
[Current sales:],
OFFSET ( -1, ALL ( 'year'[year] ), ORDERBY ( 'year'[year], ASC ) )
)
Expected result measure: =
VAR _t =
FILTER (
ADDCOLUMNS (
SUMMARIZE ( sales, client[client_id], store[store_id], 'year'[year] ),
"@current", [Current sales:],
"@prev", [Previous sales:]
),
NOT ISBLANK ( [@prev] )
)
VAR _result =
DIVIDE ( SUMX ( _t, [@current] ), SUMX ( _t, [@prev] ) ) - 1
RETURN
IF ( NOT ISBLANK ( [Previous sales:] ), _result )
It worked perfectly. Thank you so much!!
Check out the November 2025 Power BI update to learn about new features.
Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!
| User | Count |
|---|---|
| 12 | |
| 9 | |
| 8 | |
| 5 | |
| 3 |
| User | Count |
|---|---|
| 28 | |
| 22 | |
| 20 | |
| 18 | |
| 12 |