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

The Power BI DataViz World Championships are on! With four chances to enter, you could win a spot in the LIVE Grand Finale in Las Vegas. Show off your skills.

Reply
Anonymous
Not applicable

Price changes monitoring using date range

I have some data that I would like to track the changes in prices across a specified time period. I'd like to use a date slider and display the changes in prices wither as a +/- and the difference in price change. 

 

My data is only avalilable in a single data source, but i dont have a clue of how to split this into particular time snapshots.

Here's a sample of my data

StockDate Price
A1/01/202120
B2/01/202125
C3/01/202122
D4/01/202121
E5/01/202119
F6/01/202110
G7/01/202140
H8/01/202150
I9/01/202125
A10/02/202127
B10/01/202128
C11/01/2021100
A01/03/202140
B12/01/202135
C13/01/202179


I'd like to track stocks A's change in price when i select February month it shows me the previous month price is $20 and there has been a $17 change in price. How could I go about this especially with different years/months and days?


 

 

1 ACCEPTED SOLUTION
v-cazheng-msft
Community Support
Community Support

Hi @Anonymous ,

 

You may try this solution.

1 Create a Calendar table with the min date and max date from the sample data

2 Create a Month column and Month Number column

vcazhengmsft_0-1647582972399.png

 

3 Use Month column in the previous step to create a Slicer

vcazhengmsft_1-1647582972400.png

 

4 Create a Measure and use it to conditional format Price column and Stage column

Changes =
VAR selectedMon =
    CALCULATE (
        MAX ( 'Calendar'[MonNum] ),
        'Calendar'[Month] = SELECTEDVALUE ( 'Calendar'[Month] )
    )
VAR Month_No =
    MONTH ( MAX ( 'Table'[Date ] ) )
VAR MaxPrevMon =
    CALCULATE (
        MAX ( 'Table'[Date ] ),
        ALLEXCEPT ( 'Table', 'Table'[Stock ] ),
        MONTH ( 'Table'[Date ] ) = selectedMon - 1
    )
VAR MaxNextMon =
    CALCULATE (
        MAX ( 'Table'[Date ] ),
        ALLEXCEPT ( 'Table', 'Table'[Stock ] ),
        MONTH ( 'Table'[Date ] ) = selectedMon
    )
VAR MaxPrevMon_No =
    MONTH ( MaxPrevMon )
VAR MaxNextMon_No =
    MONTH ( MaxNextMon )
VAR CurrOrPrevMon =
    SWITCH (
        TRUE (),
        ( Month_No = selectedMon )
            && NOT ( ISBLANK ( MaxPrevMon ) )
                && ( MaxNextMon_No = MaxPrevMon_No + 1 ), "lightgreen",
        ( Month_No = selectedMon - 1 )
            && NOT ( ISBLANK ( MaxNextMon_No) )
                && ( MaxNextMon_No = MaxPrevMon_No + 1 ), "Yellow",
        ""
    )
RETURN
    CurrOrPrevMon

 

Then, the result should look like this.

vcazhengmsft_2-1647582972403.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

View solution in original post

3 REPLIES 3
v-cazheng-msft
Community Support
Community Support

Hi @Anonymous ,

 

You may try this solution.

1 Create a Calendar table with the min date and max date from the sample data

2 Create a Month column and Month Number column

vcazhengmsft_0-1647582972399.png

 

3 Use Month column in the previous step to create a Slicer

vcazhengmsft_1-1647582972400.png

 

4 Create a Measure and use it to conditional format Price column and Stage column

Changes =
VAR selectedMon =
    CALCULATE (
        MAX ( 'Calendar'[MonNum] ),
        'Calendar'[Month] = SELECTEDVALUE ( 'Calendar'[Month] )
    )
VAR Month_No =
    MONTH ( MAX ( 'Table'[Date ] ) )
VAR MaxPrevMon =
    CALCULATE (
        MAX ( 'Table'[Date ] ),
        ALLEXCEPT ( 'Table', 'Table'[Stock ] ),
        MONTH ( 'Table'[Date ] ) = selectedMon - 1
    )
VAR MaxNextMon =
    CALCULATE (
        MAX ( 'Table'[Date ] ),
        ALLEXCEPT ( 'Table', 'Table'[Stock ] ),
        MONTH ( 'Table'[Date ] ) = selectedMon
    )
VAR MaxPrevMon_No =
    MONTH ( MaxPrevMon )
VAR MaxNextMon_No =
    MONTH ( MaxNextMon )
VAR CurrOrPrevMon =
    SWITCH (
        TRUE (),
        ( Month_No = selectedMon )
            && NOT ( ISBLANK ( MaxPrevMon ) )
                && ( MaxNextMon_No = MaxPrevMon_No + 1 ), "lightgreen",
        ( Month_No = selectedMon - 1 )
            && NOT ( ISBLANK ( MaxNextMon_No) )
                && ( MaxNextMon_No = MaxPrevMon_No + 1 ), "Yellow",
        ""
    )
RETURN
    CurrOrPrevMon

 

Then, the result should look like this.

vcazhengmsft_2-1647582972403.png

 

Also, attached the pbix file as reference.

 

If there is any post helps, then please consider Accept it as the solution to help the other members find it more quickly. If I misunderstand your needs or you still have problems on it, please feel free to let me know. Thanks a lot!

 

Best Regards,

Community Support Team _ Caiyun

VahidDM
Super User
Super User

Hi @Anonymous 

 

Can you add more details about the desired output, or share a sample of the result here?

 


Appreciate your Kudos!!
LinkedIn: 
www.linkedin.com/in/vahid-dm/

 

 

Anonymous
Not applicable

Here's a sample file/table 

 

The idea is to monitor any changes in prices and stage for a particular stock at a particular date (month). For example if I use a Calender Month slicer (February) i should see/highlight Stock A has progressed from "In discusssion" to "Assestment" and Price changed from $50 to $94. All changes highlighted should be relative to the previous month. When I select Month (March) A should have changed from "Assestment" to "Approved" and Price has dropped to $54 from $94 in Feb. 

Hope this helps



Stock Date PriceStage
A1/01/202150In Discussion
B1/01/202144In Discussion
C1/01/202119In Discussion
D1/01/202132In Discussion
E1/01/202164In Discussion
F1/01/202150In Discussion
A2/02/202194Assestment 
B2/02/202166Assestment 
C2/02/202150Assestment 
D2/02/202125Assestment 
E2/02/2021100Assestment 
A3/03/202154Approved 
B3/03/202175Approved 
C3/03/202121Approved 
D3/03/202128Approved 
A1/04/202161Trading
B1/04/20214Trading
C1/04/202176Trading
D1/04/202148Trading
E1/04/202174Assestment 
F1/04/20210Assestment 
Y2/02/202195Trading
Z24/02/202182Approved 
M14/01/202148In Discussion
P9/03/202114In Discussion
Q6/02/202195In Discussion

 

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!

FebPBI_Carousel

Power BI Monthly Update - February 2025

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

Feb2025 NL Carousel

Fabric Community Update - February 2025

Find out what's new and trending in the Fabric community.