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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
AllanBerces
Post Prodigy
Post Prodigy

Visual Calculation_ Total per Category

Hi good day,

Can anyone help me on my visual calculation, i need total sum per category.

AllanBerces_0-1754371767294.png

OUTPUT

AllanBerces_1-1754371796249.png

Thank you

2 ACCEPTED SOLUTIONS

Hi @AllanBerces 

Please change the measure as follows which would sum up by date:

Overall Total by Cat. = 
VAR CurrentDate = SELECTEDVALUE(CatSum2[Date])
VAR CurrentGroup = SELECTEDVALUE(CatSum2[Group])
RETURN
    CALCULATE(
        SUM(CatSum2[Current Total Hrs]),
        FILTER(
            ALL(CatSum2),
            CatSum2[Date] = CurrentDate &&
            CatSum2[Group] = CurrentGroup
        )
    )

MohamedFowzan1_0-1754379042327.png

 

If you would like to particularly filter for the current date, use the following:

Overall Total by Cat. = 
VAR FixedDate = TODAY()
VAR CurrentGroup = SELECTEDVALUE(CatSum2[Group])
RETURN
    CALCULATE(
        SUM(CatSum2[Current Total Hrs]),
        FILTER(
            ALL(CatSum2),
            CatSum2[Full Date] = FixedDate &&
            CatSum2[Group] = CurrentGroup
        )
    )

 

MohamedFowzan1_1-1754379413982.png

 


If you have a flag column to filter to today's date feel free to use that as well.

As mentioned for Visual level calculation, you could use:

VisualCalcTrial =
SUMX(
    WINDOW(
        1,
        ABS,
        -1,
        ABS,
        ROWS,
        ,
        ,
        PARTITIONBY([Group])
    ),
    [Sum of Current Total Hrs]
)


but again you would have to filter by the date and add the group column


View solution in original post

Hi @AllanBerces 

For column use either of these DAX for calculated columns based on your requirement:

OverallTotalByCat_Col 2 = 
VAR CurrentDate = CatSum2[Date]
VAR CurrentGroup = CatSum2[Group]
RETURN
    CALCULATE(
        SUM(CatSum2[Current Total Hrs]),
        FILTER(
            CatSum2,
            CatSum2[Date] = CurrentDate &&
            CatSum2[Group] = CurrentGroup
        )
    )

MohamedFowzan1_0-1754385620027.png

 


With fixed date:

OverallTotalByCat_Col 2 = 
VAR FixedDate = TODAY()
VAR CurrentGroup = CatSum2[Group]
RETURN
    CALCULATE(
        SUM(CatSum2[Current Total Hrs]),
        FILTER(
            CatSum2,
            CatSum2[Full Date] = FixedDate &&
            CatSum2[Group] = CurrentGroup
        )
    )

 
Mark as solution to guide others!

View solution in original post

14 REPLIES 14
Ahmedx
Super User
Super User

pls try 

Screenshot_1.png

techies
Super User
Super User

Hi @AllanBerces please try this 

 

custom = COLLAPSE([Total amount], ROWS)

 

 

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978

Hi @techies thank you very much for the reply, but it total the total group not total by category

 

Hi @AllanBerces please check this

 

techies_0-1754383125635.png

 

― Power BI | Microsoft Fabric | PL-300 | DP-600 | Blog: medium.com/@cseprs_54978
TomMartens
Super User
Super User

Hey @AllanBerces ,

 

if you want to use a Visual Calculations you can use this formula:

Calculation = SUMX( WINDOW( 1, ABS, -1, ABS, ROWS,,,PARTITIONBY( [Cat] )), [Current Total Hrs])

 

This is how it looks like in my sample report:

image.png

 

 

 

 

 

 

 

 

 

 

 

 

Hopefully, this helps to tackle your challenge.

Regards,
Tom



Did I answer your question? Mark my post as a solution, this will help others!

Proud to be a Super User!
I accept Kudos 😉
Hamburg, Germany

Hi @TomMartens 

I still find this a limitation when we are not including the Group Column like he has asked in the output above.

From my understanding, with visual-level calculations, you can only partition or group by columns included in the visual. Measures and expressions are not accepted for PARTITIONBY in WINDOW, so the only way it would be possible to create this measure in visual level calculation:

VisualCalcTrial = SUMXWINDOW1ABS, -1ABSROWS,,,PARTITIONBY[Group] )), [Sum of Current Total Hrs])
is by adding the Group Calculated column I have mentioned above and then adding this visual calculation measure.

Haven't seen any workaround so believing its a limitations as of now. 
MohamedFowzan1
Solution Specialist
Solution Specialist

Hi @AllanBerces 

Kindly do the following:

Created the sample table:

MohamedFowzan1_0-1754372981638.png


Add this as a calculated column: 

Group = 
VAR dashPos = SEARCH("--", [Cat],, 0)
RETURN IF(dashPos > 0, LEFT([Cat], dashPos - 1), BLANK())


Then, create the following measure:

Total per Group = 
CALCULATE(
    SUM(CatSum[Current Total Hrs]),
    FILTER(
        ALL(CatSum),
        CatSum[Group] = SELECTEDVALUE(CatSum[Group])
    )
)


You will not have to add the Group column to the visual

MohamedFowzan1_1-1754373096932.png


With visual-level calculations, you can only partition or group by columns included in the visual. Measures and expressions are not accepted for PARTITIONBY in WINDOW, so the only way it would be possible to create a this measure in visual level calculation:

VisualCalcTrial = SUMX( WINDOW( 1, ABS, -1, ABS, ROWS,,,PARTITIONBY( [Group] )), [Sum of Current Total Hrs])
is by adding the Group Calculated column I have mentioned above and then adding this visual calculation measure.

MohamedFowzan1_3-1754376279298.png


Once the Group column is removed, you would notice an error:

MohamedFowzan1_2-1754376177079.png

 




 

Hi @MohamedFowzan1 @TomMartens thank you very much for the reply, but mistake on my side. the current total be duplicate according to my plan date.

AllanBerces_0-1754376041589.png

DESIRED OUTPUT

AllanBerces_1-1754376242201.png

Thank you

Hi @AllanBerces 

I believe you could still use the same Group Column and Measure that I have given above as it is still splitting by the Category based on your desired output that is South, North or SouthEast

The calculations above would still be the same
Reference:

MohamedFowzan1_0-1754377280179.png

MohamedFowzan1_1-1754377301715.png

And if your only option is to go with Visual Calculation then you will have to use this but include the Group column:

MohamedFowzan1_2-1754377437492.png

 

 

Hi @MohamedFowzan1 thank you very much, but the Overall Total by cat should be SouthEast= 44,359.18 and South =10,943.6., sum only of the current date.

Hi @AllanBerces 

Please change the measure as follows which would sum up by date:

Overall Total by Cat. = 
VAR CurrentDate = SELECTEDVALUE(CatSum2[Date])
VAR CurrentGroup = SELECTEDVALUE(CatSum2[Group])
RETURN
    CALCULATE(
        SUM(CatSum2[Current Total Hrs]),
        FILTER(
            ALL(CatSum2),
            CatSum2[Date] = CurrentDate &&
            CatSum2[Group] = CurrentGroup
        )
    )

MohamedFowzan1_0-1754379042327.png

 

If you would like to particularly filter for the current date, use the following:

Overall Total by Cat. = 
VAR FixedDate = TODAY()
VAR CurrentGroup = SELECTEDVALUE(CatSum2[Group])
RETURN
    CALCULATE(
        SUM(CatSum2[Current Total Hrs]),
        FILTER(
            ALL(CatSum2),
            CatSum2[Full Date] = FixedDate &&
            CatSum2[Group] = CurrentGroup
        )
    )

 

MohamedFowzan1_1-1754379413982.png

 


If you have a flag column to filter to today's date feel free to use that as well.

As mentioned for Visual level calculation, you could use:

VisualCalcTrial =
SUMX(
    WINDOW(
        1,
        ABS,
        -1,
        ABS,
        ROWS,
        ,
        ,
        PARTITIONBY([Group])
    ),
    [Sum of Current Total Hrs]
)


but again you would have to filter by the date and add the group column


Hi @MohamedFowzan1 @techies @Ahmedx @TomMartens thank you very much for the reply working all good, im just wondering how can i convert this also in calculated column. thank you all

Hi @AllanBerces 

For column use either of these DAX for calculated columns based on your requirement:

OverallTotalByCat_Col 2 = 
VAR CurrentDate = CatSum2[Date]
VAR CurrentGroup = CatSum2[Group]
RETURN
    CALCULATE(
        SUM(CatSum2[Current Total Hrs]),
        FILTER(
            CatSum2,
            CatSum2[Date] = CurrentDate &&
            CatSum2[Group] = CurrentGroup
        )
    )

MohamedFowzan1_0-1754385620027.png

 


With fixed date:

OverallTotalByCat_Col 2 = 
VAR FixedDate = TODAY()
VAR CurrentGroup = CatSum2[Group]
RETURN
    CALCULATE(
        SUM(CatSum2[Current Total Hrs]),
        FILTER(
            CatSum2,
            CatSum2[Full Date] = FixedDate &&
            CatSum2[Group] = CurrentGroup
        )
    )

 
Mark as solution to guide others!

Hi @MohamedFowzan1 thank you very much working perfectly

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

September Power BI Update Carousel

Power BI Monthly Update - September 2025

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

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors
Top Kudoed Authors