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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
Anonymous
Not applicable

Measure not calculating totals right values.

Hi,

Measure is not working at totals level. Created a new Measure which calculates the Prior year Sales Amount WTD, On the Power BI report there are 3 scliers to select Year, Week and Status. Here is the Dax Measure

prioryear.pngcurrentyear.pngreport.pngOn the Matix report I need show Channel ,Distrinct ,Store Number ,Status,SalesAmt , SalesAmtPy and status can change over time So when calcualting PY I need to ignore the Status from Prior Year and show only the current year Status with SalesAmt and SalesAmtPy on one line.To acheive this I used the above Calc which seems to be working fine but the totals and subtotals in matrix report or totals in tabular report are not correct. Only at the lowest level in matrix they are calculating fine. on the higher level it is not .

 

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Here is the Dax code

SalesAmtPY:=
VAR DateRange =
    FILTER (
        ALL ( 'DimDate' ),
        'DimDate'[AdjustedYearNumber]
            = VALUES ( 'DimDate'[AdjustedYearNumber] ) - 1
            && CONTAINS (
                VALUES ( 'DimDate'[AdjustedWeekofYearNumber] ),
                'DimDate'[AdjustedWeekofYearNumber], 'DimDate'[AdjustedWeekofYearNumber]
            )
            && CONTAINS (
                VALUES ( 'DimDate'[AdjustedWeekofYearandDayofWeekNumber] ),
                'DimDate'[AdjustedWeekofYearandDayofWeekNumber], 'DimDate'[AdjustedWeekofYearandDayofWeekNumber]
            )
    )

     
RETURN
    IF (
        ISBLANK ( [SalesAmt] ),
        BLANK (),
        CALCULATE ( 'FactSales'[SalesAmt], DateRange, ALL ( DimStatus[StatusDescription],DimStatus[Status] ) )
    )

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

Here is the Dax code

SalesAmtPY:=
VAR DateRange =
    FILTER (
        ALL ( 'DimDate' ),
        'DimDate'[AdjustedYearNumber]
            = VALUES ( 'DimDate'[AdjustedYearNumber] ) - 1
            && CONTAINS (
                VALUES ( 'DimDate'[AdjustedWeekofYearNumber] ),
                'DimDate'[AdjustedWeekofYearNumber], 'DimDate'[AdjustedWeekofYearNumber]
            )
            && CONTAINS (
                VALUES ( 'DimDate'[AdjustedWeekofYearandDayofWeekNumber] ),
                'DimDate'[AdjustedWeekofYearandDayofWeekNumber], 'DimDate'[AdjustedWeekofYearandDayofWeekNumber]
            )
    )

     
RETURN
    IF (
        ISBLANK ( [SalesAmt] ),
        BLANK (),
        CALCULATE ( 'FactSales'[SalesAmt], DateRange, ALL ( DimStatus[StatusDescription],DimStatus[Status] ) )
    )
Anonymous
Not applicable

Here is the Dax Code; 

SalesAmtPY:=
VAR DateRange =
    FILTER (
        ALL ( 'DimDate' ),
        'DimDate'[AdjustedYearNumber]
            = VALUES ( 'DimDate'[AdjustedYearNumber] ) - 1
            && CONTAINS (
                VALUES ( 'DimDate'[AdjustedWeekofYearNumber] ),
                'DimDate'[AdjustedWeekofYearNumber], 'DimDate'[AdjustedWeekofYearNumber]
            )
            && CONTAINS (
                VALUES ( 'DimDate'[AdjustedWeekofYearandDayofWeekNumber] ),
                'DimDate'[AdjustedWeekofYearandDayofWeekNumber], 'DimDate'[AdjustedWeekofYearandDayofWeekNumber]
            )
    )

     
RETURN
    IF (
        ISBLANK ( [SalesAmt] ),
        BLANK (),
        CALCULATE ( 'FactSales'[SalesAmt], DateRange, ALL ( DimStatus[StatusDescription],DimStatus[Status] ) )
    )

@Anonymous wrote:

Hi,

Measure is not working at totals level. Created a new Measure which calculates the Prior year Sales Amount WTD, On the Power BI report there are 3 scliers to select Year, Week and Status. Here is the Dax Measure

prioryear.pngcurrentyear.pngreport.pngOn the Matix report I need show Channel ,Distrinct ,Store Number ,Status,SalesAmt , SalesAmtPy and status can change over time So when calcualting PY I need to ignore the Status from Prior Year and show only the current year Status with SalesAmt and SalesAmtPy on one line.To acheive this I used the above Calc which seems to be working fine but the totals and subtotals in matrix report or totals in tabular report are not correct. Only at the lowest level in matrix they are calculating fine. on the higher level it is not .

 


 

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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