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

Be one of the first to start using Fabric Databases. View on-demand sessions with database experts and the Microsoft product team to learn just how easy it is to get started. Watch 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

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
v-yohua-msft
Community Support
Community Support

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

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
Las Vegas 2025

Join us at the Microsoft Fabric Community Conference

March 31 - April 2, 2025, in Las Vegas, Nevada. Use code MSCUST for a $150 discount!

Dec Fabric Community Survey

We want your feedback!

Your insights matter. That’s why we created a quick survey to learn about your experience finding answers to technical questions.

ArunFabCon

Microsoft Fabric Community Conference 2025

Arun Ulag shares exciting details about the Microsoft Fabric Conference 2025, which will be held in Las Vegas, NV.

December 2024

A Year in Review - December 2024

Find out what content was popular in the Fabric community during 2024.