Microsoft is giving away 50,000 FREE Microsoft Certification exam vouchers. Get Fabric certified for FREE! Learn more
Hello,
I have the table shown, I need a measure (1) that calculates the difference between the earliest two dates
and measure (2) how many times the price changed.
your help is highly appreciated.
Solved! Go to Solution.
Simple enough,
Cnt =
CALCULATE(
COUNTROWS( 'PRICE' ),
'PRICE'[#]
<= MAXX(
INDEX( 2, DISTINCT( 'PRICE' ), ORDERBY( 'PRICE'[Date], DESC ) ),
'PRICE'[#]
)
) - 1
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LeanAndPractise(Everyday) ) |
Hi,
PBI file attached.
Hope this helps.
Simple enough,
Cnt =
CALCULATE(
COUNTROWS( 'PRICE' ),
'PRICE'[#]
<= MAXX(
INDEX( 2, DISTINCT( 'PRICE' ), ORDERBY( 'PRICE'[Date], DESC ) ),
'PRICE'[#]
)
) - 1
Expertise = List.Accumulate( {Days as from Today}, {Skills and Knowledge}, (Current, Everyday) => Current & Day.LeanAndPractise(Everyday) ) |
Hi,
I am not sure how your semantic model looksl like but please check the below picture and the attached pbix file.
INDEX function (DAX) - DAX | Microsoft Learn
latest date value vs. second latest date value: =
VAR _t =
FILTER (
ALL ( 'Calendar'[Date] ),
CALCULATE ( SUM ( Data[Price] ) ) <> BLANK ()
)
VAR _latest =
CALCULATE (
SUM ( Data[Price] ),
INDEX ( 1, _t, ORDERBY ( 'Calendar'[Date], DESC ) )
)
VAR _second =
CALCULATE (
SUM ( Data[Price] ),
INDEX ( 2, _t, ORDERBY ( 'Calendar'[Date], DESC ) )
)
RETURN
IF ( HASONEVALUE ( 'ID'[ID] ), _latest - _second )
OFFSET function (DAX) - DAX | Microsoft Learn
price change count: =
VAR _nonblankdate =
FILTER (
VALUES ( 'Calendar'[Date] ),
CALCULATE ( SUM ( Data[Price] ) ) <> BLANK ()
)
VAR _t =
FILTER (
ADDCOLUMNS (
SUMMARIZE ( Data, 'Calendar'[Date] ),
"@current", CALCULATE ( SUM ( Data[Price] ) ),
"@prev",
CALCULATE (
SUM ( Data[Price] ),
OFFSET ( -1, _nonblankdate, ORDERBY ( 'Calendar'[Date], ASC ) )
)
),
[@prev] <> BLANK ()
)
RETURN
IF (
HASONEVALUE ( 'ID'[ID] ),
COUNTROWS ( FILTER ( _t, [@current] <> [@prev] ) )
)
If this post helps, then please consider accepting it as the solution to help other members find it faster, and give a big thumbs up.
Check out the April 2025 Power BI update to learn about new features.
Explore and share Fabric Notebooks to boost Power BI insights in the new community notebooks gallery.
User | Count |
---|---|
105 | |
68 | |
47 | |
42 | |
39 |