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

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

Dynamic Measure

Hi, 

 

I'm creating a point in time report which requires a number of Dynamic components. I have the majority of them in the report but I seem to have fallen at the last hurdel. In the Screen shot below, I would like the last column 'TEST 0-30 days' measure to;

Sum "Balance" if "Age Category" = "0-30 days".

 

Dynamic Days - Visuals.JPG

 

I'll break down each step below.

 

  1. Balance = a field from the data sourceDate_Selected 
  2. Date_Selected = CALCULATE(MAX('Date_Table'[Date]),ALLSELECTED('Date_Table'))
  3. Doc_Age = ([Date_Selected] - MAX([Document.c2g__DueDate__c])) * 1
  4. Age Category =
    IF([Doc_Age] < 1 ,"Current",
    IF([Doc_Age] < 30, "0-30 days",
    IF([Doc_Age] < 60, "31-60 days",
    IF([Doc_Age] < 90, "61-90 days",
    IF([Doc_Age] > 90, "90+ days", "Check")
    ))))​
  5. TEST 0-30 days = SUMX('Transaction Line Item',
    if ('Key Measures'[Age Category]="0-30 days",
    CALCULATE(SUM('Transaction Line Item'[Balance])),
    BLANK()))

 

So Point number 5 doesn't seem to work, I also tired the point below and this threw an error.

 

  1. Test 0-30 days = CALCULATE(SUM(Transaction Line Item'[Balance]),'Key Measures'[Age Category]="0-30 days")

From a model point of view the only tables relevent to these calculations are the DATE table and Transaction line item. these are linked by Date_Table[Date] to 'Transaction Line Item'[CreatedDate] on a 1:* relationship.

 

Dynamic Days - Model.JPG

 

As always any help is greatly aprriciated. 

 

Thanks 

Dobby Libr3

 

2 ACCEPTED SOLUTIONS

SUMX(FILTER('Transaction Line Item','Key Measures'[Age Category]="0-30 days"),[Balance])

 

?

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...

View solution in original post

ImkeF
Community Champion
Community Champion

Hi @Anonymous ,

for these kind of measures, deleting the connection between your date table and the fact table should help.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

View solution in original post

12 REPLIES 12
amitchandak
Super User
Super User

Row context is very important for measure


TEST 0-30 days = SUMX(summarize('Transaction Line Item','Transaction Line Item'[DocId],"_sum"
if ('Key Measures'[Age Category]="0-30 days",
CALCULATE(SUM('Transaction Line Item'[Balance])),
BLANK()))[_sum]

)

 

Also, if possible filter on age in the formula, not on the age category

Share with Power BI Enthusiasts: Full Power BI Video (20 Hours) YouTube
Microsoft Fabric Series 60+ Videos YouTube
Microsoft Fabric Hindi End to End YouTube
Anonymous
Not applicable

Hi @amitchandak 

 

Thanks for getting back to me, I used your code and I'm still getting blanks!

 

Blanks.JPG

 

 

@Anonymous I don't see Key Measures table in your model, what is that and how is it connected? Is Age Category a column or a measure? Is TEST 0-30 days supposed to be a measure or a calculated column? If calculated column what table?

 

TEST 0-30 days = SUMX('Transaction Line Item',
if ('Key Measures'[Age Category]="0-30 days",
CALCULATE(SUM('Transaction Line Item'[Balance])),
BLANK()))



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler,

 

The Key Measure table is just a table where I keep all my measures, its stand alone and doesn't connect to the model. 

 

Age Category is currently a measure because as a colum it doesn't return the correct value. 

 

Age Cat Col.JPG

 

In an ideal world I would have these all as columns rather than measures, 

 

Thanks

Rob 

 

 

Or perhaps:

 

SUMX(
  FILTER(
    ADDCOLUMS(
      'Transaction Line Item',
      "__Age Category",'Key Measures'[Age Category]
    ),
    [__Age Category]="0-30 days"
  ),
  [Balance]
)


Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
Anonymous
Not applicable

Hi @Greg_Deckler , @ImkeF and @amitchandak

 

Unfortuantly none of those worked! thanks you so much for investing your time in this, I have got a sample PBIX below, is there somthing wrong with my data model maybe? 

 

https://drive.google.com/file/d/1o694rGjYHVia0xpwzq75Dl920fLK4_qC/view?usp=sharing

 

As always any help is appriciated and never expected!

 

Thanks 

 

Dobby 

ImkeF
Community Champion
Community Champion

Hi @Anonymous ,

for these kind of measures, deleting the connection between your date table and the fact table should help.

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

Thanks @ImkeF this has worked, I really don't understand why! thanks all for your help

SUMX(FILTER('Transaction Line Item','Key Measures'[Age Category]="0-30 days"),[Balance])

 

?

 

 



Follow on LinkedIn
@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
DAX For Humans

DAX is easy, CALCULATE makes DAX hard...
ImkeF
Community Champion
Community Champion

Hi @Anonymous 

please try the following:

 

CALCULATE(

SUMX(
    VALUES('Transaction Line Item'[Trans Line Item]),

    CALCULATE(SUM('Transaction Line Item'[Balance]))),
    'Key Measures'[Age Category]="0-30 days")

 

 

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Anonymous
Not applicable

Hi @ImkeF 

 

I tried a Calculate column before and I got this error. 

 

"A function 'CALCULATE' has been used in a True/False expression that is used as a table filter expression. This is not allowed."

 

This same error appeared when I tired this expression.

ImkeF
Community Champion
Community Champion

Hi @Anonymous 

have you tried @amitchandak  's proposal?

 

Otherwise: Could you please share a sample workbook?

Imke Feldmann (The BIccountant)

If you liked my solution, please give it a thumbs up. And if I did answer your question, please mark this post as a solution. Thanks!

How to integrate M-code into your solution -- How to get your questions answered quickly -- How to provide sample data -- Check out more PBI- learning resources here -- Performance Tipps for M-queries

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

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