cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
SRI327 Regular Visitor
Regular Visitor

Show Current year Sales and Prior Year Sales in One line

Hi,

I'm trying to create a DAX Measure for Prior year and need some help. My Model has one Fact Table and 4 dimensions. FactSales, DimStore, DimDate, DimCompStatus, DimStyle. DimCompStatus has data this way ; for each week and for each Store their Status is Stored. Here is an example of how Prior Year values shows up because of CompStatus of a Store. Store_PY.png

For Store 402 and 412 there are 2 lines because the compStatus of last year is different. I would like to see the current year comp status and SalesAmt and SalesAmtpy in one line like this;

402 C 34325 40349

412 O 66347 68893

 

Here is my PY Calc 

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

Thanks

 

 

4 REPLIES 4
Super User
Super User

Re: Show Current year Sales and Prior Year Sales in One line

See if my Time Intelligence the Hard Way provides a different way of accomplishing what you are going for.

https://community.powerbi.com/t5/Quick-Measures-Gallery/Time-Intelligence-quot-The-Hard-Way-quot-TIT...


I have book! Learn Power BI from Packt


Did I answer your question? Mark my post as a solution!

Proud to be a Datanaut!

Highlighted
SRI327 Regular Visitor
Regular Visitor

Re: Show Current year Sales and Prior Year Sales in One line

I tried your Measure, didn't work for me. Thanks!!

Community Support Team
Community Support Team

Re: Show Current year Sales and Prior Year Sales in One line

Hi @SRI327 

Hi @SRI327 

Do you have date column(of date format) or only "year","day" (of number format) columns in the dataset?

It is important for me to know so to decide if we can use time intelligence function as this thread

 

 

Best Regards
Maggie
Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
kamalmsharma Regular Visitor
Regular Visitor

Re: Show Current year Sales and Prior Year Sales in One line

Hi Sri,

 

Try using ALL(tablename, tablename[compstatuscode]) as a filtering condition to your salesamount measure for cuurent year as well as last year. This will ignore compstatus code column as a filtering condition in the table.

 

Cheers

Kamal

www.addendanal 

Helpful resources

Announcements
New Kudos Received Badges Coming

New Kudos Received Badges Coming

Kudos to you if you earned one of these! Check your inbox for a notification.

Microsoft Implementation for Communities Wins Award

Microsoft Implementation for Communities Wins Award

Learn about the award-winning innovation that was implemented across Microsoft’s Business Applications Communities.

Power Platform World Tour

Power Platform World Tour

Find out where you can attend!

Top Kudoed Authors (Last 30 Days)
Users online (1,795)