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

Show sales and no sales in same visual but only for available products

Hi all,

 

I have a set of tables I want to build a visual from to show, for a customer, all available products to them, and any sales that have already happened. Here is the table structure (the formatting isn't helpful on here for tables but thought the data can be copied and pasted out easily to recreate the structure)

 

Customers table

IDArea
C1Germany
C2Germany
C3France
C4Spain

 

Product availability table

AreaProduct
GermanyA
GermanyB
GermanyC
FranceA
FranceB
FranceC
SpainA
SpainB
SpainC
SpainD

 

Sales table

IDProductQuantity
C1A10
C1B20
C1C30
C2A100
C2C50
C4B25


  

The way i want the final visual to work is:

  • choose a customer ID
  • visual shows the products available only in their area
  • alongside the products, visual displays any quantities that have been sold

 

So depending on the customer selected, the visual would work as follows:

  • customer C1 would show products A, B and C being available, and also quantities sold for each
  • customer C2 would show products A, B and C being available, but only quantities against A and C
  • customer C3 would show products A, B and C being available, but no quantities for any
  • customer C4 would show products A, B, C and D being available, but only quantities against B

 

Though the relationships between tables is intuitive, I can't figure out how to achieve the visual when combining with "Show items with no data" because (for example) doing so incorrectly shows customer C2 having product D being available.

 

I also want to introduce a "time available" dimension to the model want to understand how to do this generically that I can extend to other columns, if that's possible!

 

How can this be done?

 

Thanks for any help or advice!

1 ACCEPTED SOLUTION
Eric_Zhang
Employee
Employee

@bms2017

I tried to add a area table and create relationship as below.

Capture2.PNG

 

Then create a measure as below and then the visual show as expected.

Quantity measure = 
VAR val =
    CALCULATE (
        SUM ( Sales[Quantity] ),
        FILTER (
            Sales,
            Sales[Product] = LASTNONBLANK ( 'Product availability'[Product], "" )
        )
    )
RETURN
    IF (
        ISBLANK ( val )
            && NOT ( ISBLANK ( LASTNONBLANK ( 'Product availability'[Product], "" ) ) ),
        0,
        val
    )

Capture.PNG

 

See more details in the attached pbix file.

 

View solution in original post

2 REPLIES 2
Eric_Zhang
Employee
Employee

@bms2017

I tried to add a area table and create relationship as below.

Capture2.PNG

 

Then create a measure as below and then the visual show as expected.

Quantity measure = 
VAR val =
    CALCULATE (
        SUM ( Sales[Quantity] ),
        FILTER (
            Sales,
            Sales[Product] = LASTNONBLANK ( 'Product availability'[Product], "" )
        )
    )
RETURN
    IF (
        ISBLANK ( val )
            && NOT ( ISBLANK ( LASTNONBLANK ( 'Product availability'[Product], "" ) ) ),
        0,
        val
    )

Capture.PNG

 

See more details in the attached pbix file.

 

Eric, thanks very much for your help on this - works perfectly, just what I wanted.

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.