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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
rexeubank
New Member

Sales Data Pre/Post a Specific Date

Hello,

 

I'm having trouble with a calculated column. I am trying to see sales data 3 weeks prior and post-visitation to a store so I can compare with the week that the store is visited.

 

I have the formula in a calculated column below, which matches the sales data store number & week number to that of the store visitation export (I just add a +1 or -1 to change the week number for pre- and post-visitation weeks).

Current Week =
SUMX(
FILTER(
'Sales',
AND(
'Sales'[Week Number] = 'Combined Recaps'[WM Week],
'Sales'[Store Number] = 'Combined Recaps'[Retail ID]
)
),
'Sales'[Sales]
)
 
The columns work just fine, the issue comes when I'm trying to filter the sales data by brand or type of sale. I believe I need to put this formula into a measure somehow, but I can't figure out a formula that works.
 
Any help is much appreciated! Thank you.
1 ACCEPTED SOLUTION

Hi @rexeubank 

 

The claculated column can't be changed by the other table's filter. I believe you can achieve this by changing it to the measure as below:

Measure = SUMX(
        FILTER(
            ALLSELECTED('Sales'),
            AND(
                'Sales'[Week Number] = MAX('Combined Recaps'[WM Week]),
                'Sales'[Store Number] = MAX('Combined Recaps'[Retail ID])
            )
        ),
        'Sales'[Sales]
    )

04.gif

Community Support Team _ Dina Ye
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

4 REPLIES 4
amitchandak
Super User
Super User

@rexeubank , refer my post on week can help you

 

https://medium.com/@amitchandak.1978/power-bi-wtd-questions-time-intelligence-4-5-98c30fab69d3
https://community.powerbi.com/t5/Community-Blog/Week-Is-Not-So-Weak-WTD-Last-WTD-and-This-Week-vs-La...

example

Week Rank = RANKX(all('Date'),'Date'[Week Start date],,ASC,Dense)	
This Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])))
Last Week = CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=max('Date'[Week Rank])-1))
Last year Week= CALCULATE(sum('order'[Qty]), FILTER(ALL('Date'),'Date'[Week Rank]=(max('Date'[Week Rank]) -52)))
Greg_Deckler
Super User
Super User

@rexeubank - Yeah, you need to use an aggregator around your column references in a measure. Hard to be more specific, Not really enough information to go on, please first check if your issue is a common issue listed here: https://community.powerbi.com/t5/Community-Blog/Before-You-Post-Read-This/ba-p/1116882

Also, please see this post regarding How to Get Your Question Answered Quickly: https://community.powerbi.com/t5/Community-Blog/How-to-Get-Your-Question-Answered-Quickly/ba-p/38490

The most important parts are:
1. Sample data as text, use the table tool in the editing bar
2. Expected output from sample data
3. Explanation in words of how to get from 1. to 2.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

I apologize for the vagueness. Maybe this can help:

 

Below is my data.

On the top, I have the visitation export (what stores were visited and when). This is where the calculated columns are located.

On the bottom is the sales data. I match the week numbers and the store numbers (Retail ID/Store Number) and sum the sales data based on those two criteria.

And the calculated column code for easier viewing.

I need to get the weekly sales into a format where I can filter them by the Brand & Type from the Sales tab.

 

Current Week =
   SUMX(
        FILTER(
            'Sales',
            AND(
                'Sales'[Week Number] = 'Combined Recaps'[WM Week],
                'Sales'[Store Number] = 'Combined Recaps'[Retail ID]
            )
        ),
        'Sales'[Sales]
    )

 

C2112PNG.PNGCa121212e.PNG

Hi @rexeubank 

 

The claculated column can't be changed by the other table's filter. I believe you can achieve this by changing it to the measure as below:

Measure = SUMX(
        FILTER(
            ALLSELECTED('Sales'),
            AND(
                'Sales'[Week Number] = MAX('Combined Recaps'[WM Week]),
                'Sales'[Store Number] = MAX('Combined Recaps'[Retail ID])
            )
        ),
        'Sales'[Sales]
    )

04.gif

Community Support Team _ Dina Ye
If this post helps, then please consider Accept it as the solution to help the other members find it more
quickly.

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

Check out the April 2024 Power BI update to learn about new features.

April Fabric Community Update

Fabric Community Update - April 2024

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