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

Join us for an expert-led overview of the tools and concepts you'll need to become a Certified Power BI Data Analyst and pass exam PL-300. Register now.

Reply
jit
Regular Visitor

Custom tables with custom queries and calculations

Hi, I am trying to convert this excel table calculation into PowerBI but I cant seem to be able to modify the tables extensively and create the desired output of my table. Somehow powerBI can only have 1 column and 1 row variable. Is it possible for me to have multiple variables?

 

For example here is a mock table :

Withdrawal rate = withdrawal numbers(notshown) / total number(Right above it)

Capture.PNG

 

 

1 ACCEPTED SOLUTION
v-juanli-msft
Community Support
Community Support

Hi @jit 

Assume you have data as below

group name value date withdrawal numbers
G1 withdrawal rate 100 1/1/2019 40
G2 withdrawal rate 200 1/1/2019 50
G3 withdrawal rate   1/1/2019 10
G4 withdrawal rate 300 1/1/2019 50
G5 withdrawal rate 400 1/1/2019 80
G1 withdrawal rate 200 2/1/2019 60
G2 withdrawal rate 300 2/1/2019 50
G3 withdrawal rate 400 2/1/2019 40
G4 withdrawal rate 500 2/1/2019 60
G5 withdrawal rate 100 2/1/2019 30

 

Please create measures

YTD =
VAR ytd_value =
    CALCULATE (
        SUM ( Sheet3[value] ),
        FILTER ( ALLSELECTED ( Sheet3 ), Sheet3[group] = MAX ( Sheet3[group] ) )
    )
VAR next_level =
    FORMAT ( MAX ( Sheet3[withdrawal numbers] ) / ytd_value, "0.00%" )
RETURN
    IF (
        ISINSCOPE ( Sheet3[name] ),
        IF ( ytd_value = BLANK (), "0%", next_level ),
        ytd_value
    )


Jan =
VAR jan_value =
    CALCULATE (
        SUM ( Sheet3[value] ),
        FILTER (
            ALLSELECTED ( Sheet3 ),
            Sheet3[group] = MAX ( Sheet3[group] )
                && MONTH ( Sheet3[date] ) = 1
        )
    )
VAR next_level_jan =
    FORMAT ( MAX ( Sheet3[withdrawal numbers] ) / jan_value, "0.00%" )
RETURN
    IF (
        ISINSCOPE ( Sheet3[name] ),
        IF ( jan_value = BLANK (), "0%", next_level_jan ),
        jan_value
    )


Feb =
VAR feb_value =
    CALCULATE (
        SUM ( Sheet3[value] ),
        FILTER (
            ALLSELECTED ( Sheet3 ),
            Sheet3[group] = MAX ( Sheet3[group] )
                && MONTH ( Sheet3[date] ) = 2
        )
    )
VAR next_level_feb =
    FORMAT ( MAX ( Sheet3[withdrawal numbers] ) / feb_value, "0.00%" )
RETURN
    IF (
        ISINSCOPE ( Sheet3[name] ),
        IF ( feb_value = BLANK (), "0%", next_level_feb ),
        feb_value
    )

Add them in a matrix visual

9.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

View solution in original post

4 REPLIES 4
v-juanli-msft
Community Support
Community Support

Hi @jit 

Assume you have data as below

group name value date withdrawal numbers
G1 withdrawal rate 100 1/1/2019 40
G2 withdrawal rate 200 1/1/2019 50
G3 withdrawal rate   1/1/2019 10
G4 withdrawal rate 300 1/1/2019 50
G5 withdrawal rate 400 1/1/2019 80
G1 withdrawal rate 200 2/1/2019 60
G2 withdrawal rate 300 2/1/2019 50
G3 withdrawal rate 400 2/1/2019 40
G4 withdrawal rate 500 2/1/2019 60
G5 withdrawal rate 100 2/1/2019 30

 

Please create measures

YTD =
VAR ytd_value =
    CALCULATE (
        SUM ( Sheet3[value] ),
        FILTER ( ALLSELECTED ( Sheet3 ), Sheet3[group] = MAX ( Sheet3[group] ) )
    )
VAR next_level =
    FORMAT ( MAX ( Sheet3[withdrawal numbers] ) / ytd_value, "0.00%" )
RETURN
    IF (
        ISINSCOPE ( Sheet3[name] ),
        IF ( ytd_value = BLANK (), "0%", next_level ),
        ytd_value
    )


Jan =
VAR jan_value =
    CALCULATE (
        SUM ( Sheet3[value] ),
        FILTER (
            ALLSELECTED ( Sheet3 ),
            Sheet3[group] = MAX ( Sheet3[group] )
                && MONTH ( Sheet3[date] ) = 1
        )
    )
VAR next_level_jan =
    FORMAT ( MAX ( Sheet3[withdrawal numbers] ) / jan_value, "0.00%" )
RETURN
    IF (
        ISINSCOPE ( Sheet3[name] ),
        IF ( jan_value = BLANK (), "0%", next_level_jan ),
        jan_value
    )


Feb =
VAR feb_value =
    CALCULATE (
        SUM ( Sheet3[value] ),
        FILTER (
            ALLSELECTED ( Sheet3 ),
            Sheet3[group] = MAX ( Sheet3[group] )
                && MONTH ( Sheet3[date] ) = 2
        )
    )
VAR next_level_feb =
    FORMAT ( MAX ( Sheet3[withdrawal numbers] ) / feb_value, "0.00%" )
RETURN
    IF (
        ISINSCOPE ( Sheet3[name] ),
        IF ( feb_value = BLANK (), "0%", next_level_feb ),
        feb_value
    )

Add them in a matrix visual

9.png

 

Best Regards
Maggie

 

Community Support Team _ Maggie Li
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

artemus
Microsoft Employee
Microsoft Employee

You can reference a query (Right click and choose reference, or under Manage button). After creating a couple of references, you can use remove alternating rows in one, and replace "Withdrawl Rate" with null -> fill down -> remove the other alternating rows in the other query, and finally merge them together

jit
Regular Visitor

Hey @artemus thanks for the quick response. I can't quite follow what you are saying... Is it possible for you to show some screenshots/examples? Thanks so much!

artemus
Microsoft Employee
Microsoft Employee

custom column.PNG

Helpful resources

Announcements
Join our Fabric User Panel

Join our Fabric User Panel

This is your chance to engage directly with the engineering team behind Fabric and Power BI. Share your experiences and shape the future.

June 2025 Power BI Update Carousel

Power BI Monthly Update - June 2025

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

June 2025 community update carousel

Fabric Community Update - June 2025

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

Top Solution Authors