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

Get Fabric Certified for FREE during Fabric Data Days. Don't miss your chance! Learn more

Reply
Anonymous
Not applicable

Count the number of Ids with decreases in a time series

Hi,

 

I'm really stuck on this one so I appreciate any help.

Say I have a time series table called Charges where the Charges can vary over time for any person. I want a create measure to count the number of people with a decrease in charge between the first and last dates. This will need to be affected by a date slicer. 

 

PersonDateCharge
101/04/2022320
102/04/2022320
103/04/2022320
104/04/2022320
105/04/2022320
106/04/2022330
107/04/2022330
201/04/2022320
202/04/2022320
203/04/2022320
204/04/2022340
205/04/2022340
206/04/2022340
207/04/2022340
301/04/2022300
302/04/2022310
303/04/2022300
304/04/2022300
305/04/2022300
306/04/2022300
307/04/2022300
403/04/2022300
404/04/2022300
405/04/2022300
406/04/2022300
407/04/2022200
408/04/2022200


I tried this sort of thing, but it's returning blank. The expected output would be 1 for person 4 who goes from a charge of 300 to 200 on the last day.

 

 

 

 

Number of people with decreases = 
    var gp = FILTER(
                ADDCOLUMNS(
                    SUMMARIZECOLUMNS(
                        Charges[Person], 
                        "First rate", FIRSTNONBLANK(Charges[Charge], TRUE()), 
                        "Last rate", LASTNONBLANK(Charges[Charge], TRUE())),
                    "Change", [Last rate]<>[First rate]
                ), 
                [Last rate]<[First rate]
            )
return 
    countrows(gp)

 

 

 

 

 

Here's a link to a test pbix https://drive.google.com/file/d/1ob-94FmdOAwr_NwaIgi2YxL0-G0Qk8Bs/view?usp=share_link 

 

 

1 ACCEPTED SOLUTION
Mikelytics
Resident Rockstar
Resident Rockstar

HI @Anonymous 

 

Can you please try

 

 

Number of people with decreases = 

SUMX(
   VALUES(Table[Person]),
   var FirstDayRate = CALCULATE(MAX(Table[Charge],FIRSTDATE(Table[Date]))
   var LastDayRate = CALCULATE(MAX(Table[Charge],LASTDATE(Table[Date]))
   RETURN
   IF(LastDayRate<FirstDayRate,1,0)
)

 

 

OR

Number of people with decreases =

SUMX(
VALUES(Table[Person]),
var FirstDayRate = CALCULATE(MAX(Table[Charge],FILTER(Table,FIRSTDATE(Table[Date])))
var LastDayRate = CALCULATE(MAX(Table[Charge],FILTER(Table,LASTDATE(Table[Date])))
RETURN
IF(LastDayRate<FirstDayRate,1,0)
)

 

 

Best regards

Michael

-----------------------------------------------------

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

@ me in replies or I'll lose your thread.

-----------------------------------------------------

LinkedIn

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

View solution in original post

2 REPLIES 2
Anonymous
Not applicable

@Mikelytics thanks - I think that might be it!

Mikelytics
Resident Rockstar
Resident Rockstar

HI @Anonymous 

 

Can you please try

 

 

Number of people with decreases = 

SUMX(
   VALUES(Table[Person]),
   var FirstDayRate = CALCULATE(MAX(Table[Charge],FIRSTDATE(Table[Date]))
   var LastDayRate = CALCULATE(MAX(Table[Charge],LASTDATE(Table[Date]))
   RETURN
   IF(LastDayRate<FirstDayRate,1,0)
)

 

 

OR

Number of people with decreases =

SUMX(
VALUES(Table[Person]),
var FirstDayRate = CALCULATE(MAX(Table[Charge],FILTER(Table,FIRSTDATE(Table[Date])))
var LastDayRate = CALCULATE(MAX(Table[Charge],FILTER(Table,LASTDATE(Table[Date])))
RETURN
IF(LastDayRate<FirstDayRate,1,0)
)

 

 

Best regards

Michael

-----------------------------------------------------

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

@ me in replies or I'll lose your thread.

-----------------------------------------------------

LinkedIn

------------------------------------------------------------------
Visit my blog datenhungrig which I recently started with content about business intelligence and Power BI in German and English or follow me on LinkedIn!

Helpful resources

Announcements
Fabric Data Days Carousel

Fabric Data Days

Advance your Data & AI career with 50 days of live learning, contests, hands-on challenges, study groups & certifications and more!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

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

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