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

Don't miss out! 2025 Microsoft Fabric Community Conference, March 31 - April 2, Las Vegas, Nevada. Use code MSCUST for a $150 discount. Prices go up February 11th. Register now.

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Jan25PBI_Carousel

Power BI Monthly Update - January 2025

Check out the January 2025 Power BI update to learn about new features in Reporting, Modeling, and Data Connectivity.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.