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

Enhance your career with this limited time 50% discount on Fabric and Power BI exams. Ends August 31st. Request your voucher.

Reply
ldsmith919
Frequent Visitor

Displaying categories with no data and category calc based on existing values in the same field

Hello there!

 

Here is my current data and matrix visual (sample data).  

MaterialLocationLead TimeCategoryDateQuantity
A-110015Available11/20/2024100
A-110015Planned Demand1/6/202550
A-210012Available11/20/202420
A-220012Available11/20/202420
A-220012Firm Demand11/30/202460
A-220012Planned Demand11/30/202440
A-310010Available11/20/202415
A-310010Planned Orders12/16/202445
B-110018Available11/20/202430
B-220015Available11/20/202455
B-220015Firm Orders12/13/202425
B-220015Planned Demand12/13/202460
B-220015Planned Orders1/6/202540
B-220015Firm Demand1/6/202575
B-31005Available11/20/202410
B-32005Available11/20/202440
B-31005Planned Orders11/30/202450
B-31005Firm Demand12/16/202460

 

ldsmith919_0-1732117578737.png

 

I have a couple of problems I'm trying to solve:

1.  How can I display all the categories even if there is no data for that category?  I'm fine with it displaying a zero, though I would prefer it to be blank.  It would look like this:

ldsmith919_2-1732117946596.png

 

2.  How can I create a calculation that sums multiple other categories within an existing category?

Currently, I already have an "Available" category.  However, I would want the new available category to be calulated such that the result is New Available = Old Available + Firm Orders + Planned Orders - Firm Demand - Planned Demand.  You can see those values in the screenshot above.

 

Any help that can be provided would be greatly appreciated!

 

 

1 ACCEPTED SOLUTION
DataInsights
Super User
Super User

@ldsmith919,

 

This can be achieved with a disconnected table such as the one below. It has no relationships with other tables. The Index column allows you to sort Category by Index.

 

DataInsights_0-1732129140713.png

 

DataInsights_1-1732129197901.png

 

Create measures:

 

Sum Quantity = SUM ( FactTable[Quantity] )
Quantity Switch = 
SWITCH (
    SELECTEDVALUE ( Category[Category] ),
    "New Available",
        CALCULATE (
            [Sum Quantity],
            FactTable[Category] IN { "Available", "Firm Orders", "Planned Orders" }
        )
            - CALCULATE (
                [Sum Quantity],
                FactTable[Category] IN { "Firm Demand", "Planned Demand" }
            ),
    CALCULATE (
        [Sum Quantity],
        TREATAS ( VALUES ( Category[Category] ), FactTable[Category] )
    )
)

 

In the matrix, use Category[Category] (disconnected table). Click the down arrow for Category in the Rows field well and select "Show items with no data".

 

DataInsights_2-1732129371917.png

 

DataInsights_3-1732129462524.png

 

 





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

Proud to be a Super User!




View solution in original post

3 REPLIES 3
DataInsights
Super User
Super User

@ldsmith919,

 

This can be achieved with a disconnected table such as the one below. It has no relationships with other tables. The Index column allows you to sort Category by Index.

 

DataInsights_0-1732129140713.png

 

DataInsights_1-1732129197901.png

 

Create measures:

 

Sum Quantity = SUM ( FactTable[Quantity] )
Quantity Switch = 
SWITCH (
    SELECTEDVALUE ( Category[Category] ),
    "New Available",
        CALCULATE (
            [Sum Quantity],
            FactTable[Category] IN { "Available", "Firm Orders", "Planned Orders" }
        )
            - CALCULATE (
                [Sum Quantity],
                FactTable[Category] IN { "Firm Demand", "Planned Demand" }
            ),
    CALCULATE (
        [Sum Quantity],
        TREATAS ( VALUES ( Category[Category] ), FactTable[Category] )
    )
)

 

In the matrix, use Category[Category] (disconnected table). Click the down arrow for Category in the Rows field well and select "Show items with no data".

 

DataInsights_2-1732129371917.png

 

DataInsights_3-1732129462524.png

 

 





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

Proud to be a Super User!




So my business users decided to add one more layer of complexity to the calculation where the "New Available" quantity is the same as the previous date (I'm using date bins) unless new demand or orders are added (red).  This would mean all date bins show up (green) and the total would reflect final state (blue).  This what the data should look like with the new calculation in place.  With the orinigal problem's complexity, the different solution I've tried using MAX, SUMX and EARLIER have not worked.

 

ldsmith919_0-1732729192254.png

 

 

This worked perfectly, thank you so much!

Helpful resources

Announcements
July 2025 community update carousel

Fabric Community Update - July 2025

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

July PBI25 Carousel

Power BI Monthly Update - July 2025

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