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

Grow your Fabric skills and prepare for the DP-600 certification exam by completing the latest Microsoft Fabric challenge.

Reply
jhollingworth
Frequent Visitor

Help with counting when comparing to previous columns

Hello,
I'm hoping this is simple, but I can't seem to figure it out.

I have a sheet of data that has the number on hand of items based on dates:

DateItemsCount Sum
4/18/2024Bike5
4/18/2024Car-1
4/18/2024Motorcycle-3
4/10/2024Bike-1
4/10/2024Car1
4/10/2024Motorcycle2
4/1/2024Bike5
4/1/2024Car2
4/1/2024Motorcycle-2

 

I'm trying to make a Matrix in Desktop that compares the Count Sum of one date to the previous and tells me if it switched from Positive to Negative or Negative to Positive:

Type4/1/20244/10/20244/18/2024
Total Positive121
Total Negative212
Positive to Negativen/a12
Negative to Positiven/a11

 

I have the Total Positive and Total Negative working for each date but I am having trouble figuring out a formula the will evaluate each item to see if it went from positive to negative and then negative to positive.
This is as close as I have gotten:

Value =
VAR MAXD = CALCULATE( MAX ('Table1'[Date]) )
VAR PREVD = CALCULATE( MAX('Table1'[Date]), 'Table1'[Date] < MAXD )
RETURN
SWITCH(
    TRUE(),
    SELECTEDVALUE('Maxtrix'[Header#]) = Total Positive,
    CALCULATE(COUNTROWS('Table1'), 'Table1'[Count Sum]>0), **This Works**

    SELECTEDVALUE('Maxtrix'[Header#]) = Total Negative,
    CALCULATE(COUNTROWS('Table1'), 'Table1'[Count Sum]<0), **This Works**

    SELECTEDVALUE('Maxtrix'[Header#]) = Positive to Negative,
    CALCULATE(COUNTROWS('Table1'), 'Table1'[Date]=MAXD && 'Table1'[Count Sum]>0, 'Table1'[Date]=PREVD && 'Table1'[Count Sum]<0 ),
 
    SELECTEDVALUE('Maxtrix'[Header#]) = Negative to Positive,
    CALCULATE(COUNTROWS('Table1'), 'Table1'[Date]=MAXD && 'Table1'[Count Sum]<0, 'Table1'[Date]=PREVD && 'Table1'[Count Sum]>0 ),
)
 
Thank you in advance for the help!

jhollingworth_1-1713471909995.png

 


 

1 ACCEPTED SOLUTION
ThxAlot
Super User
Super User

ThxAlot_0-1713501202747.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



View solution in original post

4 REPLIES 4
ThxAlot
Super User
Super User

ThxAlot_0-1713501202747.png



Expertise = List.Accumulate(


        {Days as from Today},


        {Skills and Knowledge},


        (Current, Everyday) => Current & Day.LeanAndPractise(Everyday)


)



Hi ThxAlot,

This worked! Thank you for the help.

I do have a question about the measure you created [SUM Count Sum]. Why can't you use "SUM('Data'[Count Sum])" instead? I tried this and it didn't work, but when I created a measure like you did, it did work.

Thank you!

lbendlin
Super User
Super User

I don't see two negatives for 4/1/2024

 

lbendlin_0-1713478586347.png

Please clarify.

That was an error from me changing data to make a better example of different scenerios. ThxAlot answer it though.

Helpful resources

Announcements
Europe Fabric Conference

Europe’s largest Microsoft Fabric Community Conference

Join the community in Stockholm for expert Microsoft Fabric learning including a very exciting keynote from Arun Ulag, Corporate Vice President, Azure Data.

RTI Forums Carousel3

New forum boards available in Real-Time Intelligence.

Ask questions in Eventhouse and KQL, Eventstream, and Reflex.

MayPowerBICarousel1

Power BI Monthly Update - May 2024

Check out the May 2024 Power BI update to learn about new features.