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
keewei87
Frequent Visitor

Need help with Dax/Logic on Calculated columns for same category and same day

Dear Powerbi Gods,

 

I have 2 databases. Customer_database and Visit_database.

They are linked by Customer Name on 1 to many relationship.

 

Visit_Database

Date of VisitCustomer NameSales IndicatorCurrent Day Sales IndicatorCurrent Week Sales Indicator
11 OctCustomer AYesYesYes
11 OctCustomer ANoYesYes
10 OctCustomer BNoNoNo
1 OctCustomer BYesYesYes
1 OctCustomer CYesYesYes

 

Sales Indicator is a new column from a if else statement on the the products and denotes Yes if there is any sales done during this visit and No if no sales done during this visit.

 

I need to create 2 additional new columns

1) Current Day Sales indicator

- should denote Yes if there is any sales done for THIS CUSTOMER for THIS DAY regardless of no. of visits on the same day.

2) Current Week Sales indicator 

- should denote Yes if there is any sales done for THIS CUSTOMER for THIS WEEK regardless of no. of visits within the week.

 

My Dax is as appended but not working. 

Current Day Sales Indicator =
if('Visit_database'[Sales Indicator]="Yes", "Yes", "No")
FILTER('Visit_database', 'Visit_database[Customer] && 'Visit_database'[Date of Visit])

 

I got the logic but I do not know how to express it in DAX and not sure if I am doing the correct method.

Or maybe Current Day and Current Week indicator should be added columns in the Customer_Database instead.

 

My End Product which I am building towards to is

1) Bar chart showing Sales Done/Not Done for this customer over Days/Weeks

2) Overall Barchart how many Sales Done/Not Done over Days/Weeks

 

Have been stuck for months on this.

Grateful if you could help me. Thanks in advance!!!!

 

 

1 ACCEPTED SOLUTION
v-easonf-msft
Community Support
Community Support

Hi, @keewei87 

Try  calculated columns as below:

Current Day Sales Indicator = 
CALCULATE (
    MAX ( Visit_database[Sales Indicator] ),
    ALLEXCEPT (
        Visit_database,
        Visit_database[Date of Visit],
        Visit_database[Customer Name]
    )
)
Weeknum = WEEKNUM(Visit_database[Date of Visit]) 
Current week Sales Indicator = 
CALCULATE (
    MAX ( Visit_database[Sales Indicator] ),
    ALLEXCEPT (
        Visit_database,
        Visit_database[Weeknum],
        Visit_database[Customer Name]
    )
)

83.png

Best Regards,
Community Support Team _ Eason

 

View solution in original post

2 REPLIES 2
keewei87
Frequent Visitor

Thanks alot!! This is exactly what I needed!!!😀😀

v-easonf-msft
Community Support
Community Support

Hi, @keewei87 

Try  calculated columns as below:

Current Day Sales Indicator = 
CALCULATE (
    MAX ( Visit_database[Sales Indicator] ),
    ALLEXCEPT (
        Visit_database,
        Visit_database[Date of Visit],
        Visit_database[Customer Name]
    )
)
Weeknum = WEEKNUM(Visit_database[Date of Visit]) 
Current week Sales Indicator = 
CALCULATE (
    MAX ( Visit_database[Sales Indicator] ),
    ALLEXCEPT (
        Visit_database,
        Visit_database[Weeknum],
        Visit_database[Customer Name]
    )
)

83.png

Best Regards,
Community Support Team _ Eason

 

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.