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

Register now to learn Fabric in free live sessions led by the best Microsoft experts. From Apr 16 to May 9, in English and Spanish.

Reply
cruzp
Helper III
Helper III

Create a measure/column that gets the category value based on the selected date

 

I have a data like this in Power BI:

 

PROJECT_BKPROJECT_NAMEREVENUE_CATEGORY_BKSNAPSHOT_DATE_BK
PROJ-0021POC - Cloud RC_PS_TM07/12/2022
PROJ-0021POC - Cloud RC_PS_TM08/12/2022
PROJ-0021POC - Cloud RC_PS_TM13/11/2022
PROJ-0021POC - Cloud RC_DX_EF14/10/2022
PROJ-0021POC - Cloud RC_DX_EF15/10/2022
PROJ-0021POC - Cloud RC_DX_EF20/09/2022
PROJ-0021POC - Cloud RC_DX_EF21/09/2022
PROJ-11113DL - TokenizedDB_TD_ER23/12/2022
PROJ-11113DL - TokenizedDB_TD_ER01/12/2022

 

What I want to have are the ff:

  • A single dropdown date that contains only the values that is existing in the SNAPSHOT_DATE_BK
  • A calculated field called 'CURRENT_REVENUE_CATEGORY_BK' that shows the associated value based on what is selected on the single dropdown date

 

Expected Output Sample 1: 

 

Assuming that the single dropdown date is selected to 08/12/2022

The SELECTED_DATE_REVENUE_CATEGORY_BK field should have a value of:

  • 'RC_PS_TM' for PROJ-0021 since that is the associated REVENUE_CATEGORY_BK on 08/12/2022 for that specific project
  • Null for PROJ-1111 since it does not have a REVENUE_CATEGORY_BK on 08/12/2022

 

cruzp_0-1689155916990.png

 

Expected Output Sample 2:

Assuming that the single dropdown date is selected to 23/12/2022

The SELECTED_DATE_REVENUE_CATEGORY_BK field should have a value of:

  • Null for PROJ-0021 since it does not have a REVENUE_CATEGORY_BK on 23/12/2022
  • 'DB_TD_ER' for PROJ-1111 since that is the associated REVENUE_CATEGORY_BK on 23/12/2022 for that specific project.

 

cruzp_1-1689156136309.png

 

Kindly help  me please...

 

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

Hi , @cruzp 

Thanks for your sample data !

According to your description, you want to "Create a measure/column that gets the category value based on the selected date".

Here are the steps you can refer to :
(1)We need to click "New Table" to create a dimension table  as the date slicer:

Date = VALUES('Table'[SNAPSHOT_DATE_BK])

 

(2)Then we can create a measure like this:

SELECTED_DATE_REVENUE_CATEGORY_BK = CALCULATE( MAX('Table'[REVENUE_CATEGORY_BK])  , 'Table'[SNAPSHOT_DATE_BK]= MAX('Date'[SNAPSHOT_DATE_BK]))

 

(3)Then we can put the fields on the visual and we can get the result as follows:

vyueyunzhmsft_0-1689308583416.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

View solution in original post

3 REPLIES 3
v-yueyunzh-msft
Community Support
Community Support

Hi , @cruzp 

Thanks for your sample data !

According to your description, you want to "Create a measure/column that gets the category value based on the selected date".

Here are the steps you can refer to :
(1)We need to click "New Table" to create a dimension table  as the date slicer:

Date = VALUES('Table'[SNAPSHOT_DATE_BK])

 

(2)Then we can create a measure like this:

SELECTED_DATE_REVENUE_CATEGORY_BK = CALCULATE( MAX('Table'[REVENUE_CATEGORY_BK])  , 'Table'[SNAPSHOT_DATE_BK]= MAX('Date'[SNAPSHOT_DATE_BK]))

 

(3)Then we can put the fields on the visual and we can get the result as follows:

vyueyunzhmsft_0-1689308583416.png

 

 

 

 

If this method does not meet your needs, you can provide us with your special sample data and the desired output sample data in the form of tables, so that we can better help you solve the problem. (You can also upload you sample .pbix [without sensitive data] to the OneDrive and share with the OneDrive link to me ! )

Thank you for your time and sharing, and thank you for your support and understanding of PowerBI! 

 

Best Regards,

Aniya Zhang

If this post helps, then please consider Accept it as the solution to help the other members find it more quickly

 

HI @v-yueyunzh-msft this seems to work. how about for another field which for example the "Current Stage"
Parameters should be included in the measure:
[Stage Bk] = 'R4' 
[Stage Bk] = 'R5'

Current_Stage = 
    CALCULATE( MAX(DIM_STAGE[STAGE_BK]), 
    'Table'[SNAPSHOT_DATE_BK]= MAX('Date'[SNAPSHOT_DATE_BK]))
    )

 how do i add the parameters in the formula?

cruzp
Helper III
Helper III

can anybody help me?

Helpful resources

Announcements
Microsoft Fabric Learn Together

Microsoft Fabric Learn Together

Covering the world! 9:00-10:30 AM Sydney, 4:00-5:30 PM CET (Paris/Berlin), 7:00-8:30 PM Mexico City

PBI_APRIL_CAROUSEL1

Power BI Monthly Update - April 2024

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

April Fabric Community Update

Fabric Community Update - April 2024

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