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

Prepping for a Fabric certification exam? Join us for a live prep session with exam experts to learn how to pass the exam. Register now.

Reply
saqwild
Frequent Visitor

Calculating the amount from a helper table.

Hello Everyone.

The code I borrwed from This video.

I have two tables now, one with my master datad as following.

 

Account NumberAccount NameTransaction DateDescriptionAmount
11111Test one20/06/2024Serial one555
2222Test two16/07/2024Serio Two999

 

then 2nd the helper table

GrouporderMinMaxPercent
0-60 days106020%
61-90 days2619040%
91-120 days39112050%

 

I have just added an addition column "percent" to existing.

following below code 

 

 

outstanding = 
   CALCULATE(SUM('Extract'[Amount]),
    FILTER('Extract',
        COUNTROWS(
            FILTER('Grid',
                [Date Calc]>='Grid'[Min]&&
                [Date Calc]< 'Grid'[Max]))))

 

 

I want to calculate the "base amount" of each row with respective grid percent, based on the grid critera met.

any help on this will be highly appreciated.

 

1 ACCEPTED SOLUTION
Anonymous
Not applicable

Hi, @saqwild 

If you want to use measure. you can try the following DAX:

Base Amount with Percent measure = 
VAR DaysDiff = MAX('Master'[Days])
VAR _Percent =
    CALCULATE (
        MAX ( 'Grid'[Percent] ),
        FILTER ( 'Grid', DaysDiff >= 'Grid'[Min] && DaysDiff <= 'Grid'[Max] )
    )
RETURN
    MAX('Master'[Amount]) * _Percent

 

Here is my preview:

vyohuamsft_0-1725585041046.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

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

5 REPLIES 5
Anonymous
Not applicable

Hi, @saqwild 

Create a calculated column to calculate the date variance

Days = DATEDIFF('Master'[Transaction Date], TODAY(), DAY)

 

Then create another calculated column and try the following DAX Expression:

Base Amount with Percent =
VAR DaysDiff = 'Master'[Days]
VAR _Percent =
    CALCULATE (
        MAX ( 'Grid'[Percent] ),
        FILTER ( 'Grid', DaysDiff >= 'Grid'[Min] && DaysDiff <= 'Grid'[Max] )
    )
RETURN
    'Master'[Amount] * _Percent

 

Here is my preview:

vyohuamsft_0-1725413946602.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Thank you yongkang for your time and effort but i would prefer doing this thru a measure, tbale direct calculaiton is musch easier though

Anonymous
Not applicable

Hi, @saqwild 

If you want to use measure. you can try the following DAX:

Base Amount with Percent measure = 
VAR DaysDiff = MAX('Master'[Days])
VAR _Percent =
    CALCULATE (
        MAX ( 'Grid'[Percent] ),
        FILTER ( 'Grid', DaysDiff >= 'Grid'[Min] && DaysDiff <= 'Grid'[Max] )
    )
RETURN
    MAX('Master'[Amount]) * _Percent

 

Here is my preview:

vyohuamsft_0-1725585041046.png

 

How to Get Your Question Answered Quickly

Best Regards

Yongkang Hua

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

ryan_mayu
Super User
Super User

@saqwild 

the extract table is the first table? base amount is the amount column?

which column is date calc?

The percent column is the expected output? what's the calculation logic?





Did I answer your question? Mark my post as a solution!

Proud to be a Super User!




Applogize Ryan for the ambiguity, i have corrected the code above.

 

the extract table is the first table? base amount is the amount column?

  --- yes, extract is the first table and the amount is amount to calcualted

 

which column is date calc?

  -- is the measure to as following

 

Measure = SELECTEDVALUE('Calendar'[Date])
Date Calc = SUMX('Extract', DATEDIFF('Extract'[Transaction Date], [Measure], DAY))

 

 

The percent column is the expected output? what's the calculation logic?

  -- yes and the logic is to get the percent of amount * grid percent based on ageing of min and max
so if an amount is within the bucket of 61 to 90 the the expected output must be all amounts within this grid * 40%
 
Regads
 

Helpful resources

Announcements
PBIApril_Carousel

Power BI Monthly Update - April 2025

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

Notebook Gallery Carousel1

NEW! Community Notebooks Gallery

Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.

April2025 Carousel

Fabric Community Update - April 2025

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