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

Score big with last-minute savings on the final tickets to FabCon Vienna. Secure your discount

Reply
jc_pbi
New Member

Help in DAX formula - weekly data comparison

Hi All,

 

Good day! I just need some help on my DAX formula

 

I'm comparing weekly data. I'm comparing week 1 data of this year to the week 1 data of last year. I have already my formula and the result is correct. But there is no total at the bottom of the table visual. See below.

 

No sub total for the measure Print Cost Last YearNo sub total for the measure Print Cost Last Year

Here is the formula for the Print Cost Last Year

 

PRINT COST LAST YEAR =
     var currentyear = SELECTEDVALUE(Dates[Year])
     var lastyear = currentyear-1
     var currentweekofyear = SELECTEDVALUE(Dates[Week of Year])
     var computedPrintCostLastYr = CALCULATE([TOTAL PRINT COST],Dates[Year]=lastyear && Dates[Week of                                                            Year]=currentweekofyear)
return
      if (computedPrintCostLastYr=BLANK(),0,computedPrintCostLastYr)

 

If you need the powerbi file and the excel source file I can provide it since every data is just a sample.

 

Thank you very much.

 

 

4 REPLIES 4
amitchandak
Super User
Super User

@jc_pbi , return this and try

 

Sumx(addcolumns(summarize(Dates, Dates[Year], Dates[Week]), "_1", CALCULATE([TOTAL PRINT COST],Dates[Year]=lastyear && Dates[Week of Year]=currentweekofyear)),[_1])

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

Still with no sub total.

 

Powerbi2.png

 

Here is the whole formula.

 

PRINTCOSTLASTYEAR =
      var currentyear = SELECTEDVALUE(Dates[Year])
      var lastyear = currentyear-1
      var currentweekofyear = SELECTEDVALUE(Dates[Week of Year])
      var computedPrintCostLastYr = CALCULATE([TOTAL PRINT COST],Dates[Year]=lastyear &&                                                                         Dates[Week of Year]=currentweekofyear)
return
      Sumx(addcolumns(summarize(Dates, Dates[Year], Dates[Week of Year]), "_1", CALCULATE([TOTAL PRINT COST],Dates[Year]=lastyear && Dates[Week of Year]=currentweekofyear)),[_1])
 
or screen shot of the formula
 
pbi_dax1.png

@jc_pbi ,
Can you share sample data and sample output in table format? Or a sample pbix after removing sensitive data.

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube

Hi @amitchandak 

 

Can you download the powerbi file here.

https://1drv.ms/u/s!Ak_Zk0w2DJj5czWWdW8v7RwKGx4?e=3soHg5

 

All data are just sample. Just go the report page 3. You may ignore the others report pages.

 

Thank you very much.

Helpful resources

Announcements
August Power BI Update Carousel

Power BI Monthly Update - August 2025

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

August 2025 community update carousel

Fabric Community Update - August 2025

Find out what's new and trending in the Fabric community.