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

Earn the coveted Fabric Analytics Engineer certification. 100% off your exam for a limited time only!

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
April AMA free

Microsoft Fabric AMA Livestream

Join us Tuesday, April 09, 9:00 – 10:00 AM PST for a live, expert-led Q&A session on all things Microsoft Fabric!

March Fabric Community Update

Fabric Community Update - March 2024

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