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

Help Creating Calculated Column for Total Category Value

Hello, I need help created a static column for Total Category Value.

I only need the total category value for 1 Quarter in my entire data set.(ex: Q2) and mark rest as 0 value.

Quarter(text)        Category(text)         Sub-Category #(Text)                Value(#)                    Category Total (#)
Q1Fruit123 $   15.00 0
Q1Fruit12 $   20.000
Q1Vegetable156 $   10.00 0
Q1Vegetable152 $   20.00 0
Q2Vegetable2525 $   30.00 $               80.00
Q2Vegetable2512 $   50.00 $               80.00
Q2Fruit6433 $   10.00 $               10.00
Q3Vegetable347 $   20.00 0
Q3Vegetable3636 $   15.00 0
Q3Vegetable98 $   20.00 0
Q3Fruit6596 $   30.00 0
Q3Fruit272 $   40.000
Q4Vegetable13 $   50.00 0
Q4Fruit167 $   30.000
Q4Vegetable156 $   10.00 0

 

Thanks for the suggestions!

1 ACCEPTED SOLUTION
amitchandak
Super User
Super User

@asalazarjr , Try a new column like

if([Quarter] ="Q2", sumx(filter(table,[Quarter] = earlier([Quarter]) && [Category] = earlier([Category])),[Value]))

View solution in original post

3 REPLIES 3
Icey
Community Support
Community Support

Hi @asalazarjr ,

 

Please let us know if the replies above are helpful.

 

If they are, please always accept the replies making sense as solution to your question so that people who may have the same question can get the solution directly.

 

If not, please give us more details.

 

 

Best Regards,

Icey

amitchandak
Super User
Super User

@asalazarjr , Try a new column like

if([Quarter] ="Q2", sumx(filter(table,[Quarter] = earlier([Quarter]) && [Category] = earlier([Category])),[Value]))

mahoneypat
Employee
Employee

You can use this column expression to do that

 

Total Category =
IF (
    Table[Quarter(text)] = "Q2",
    CALCULATE (
        SUM ( Table[Value(#)] ),
        ALLEXCEPT (
            Table,
            Table[Quarter(text)],
            Table[Category(text)]
        )
    ),
    0
)

 

Regards,

Pat

 





Did I answer your question? Mark my post as a solution! Kudos are also appreciated!

To learn more about Power BI, follow me on Twitter or subscribe on YouTube.


@mahoneypa HoosierBI on YouTube


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.