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
jazzk
Helper I
Helper I

Filter values in each column based on particular day

I have a scenario where data for the year 2018, 2019 are given and new data gets uploaded everyday for 2020. Let’s say I have a column called as ‘campaign day’ which holds values from 1 to 31. Amount and other details for the year 2018 and 2019 for each campaign day is already present and the value for 2020 gets loaded as each campaign day passes. This means that the data for campaign day 1 in the year 2020 comes as each campaign day passes. Now, I want to calculate the sum of amount received in each campaign based on each campaign day for all the three years across different regions. For example, if today is the 1st day of campaign, so data for the year 2020 would have been uploaded in the database and it should show the total sum of amount in each region for the 1st day for 2018,2019 and 2020 (even though I have all the data for 2018 and 2019). Next, when the 2nd day arrives, it should calculate the sum of amount in each region for the 2nd day for 2018, 2019 and 2020 and so on for remaining campaign days. Hence, it should calculate year to date value based on campaign day.

This is how my original data would look like:

RegionCampaign DayAmount Year
East 1252018
East2202018
East 3302018
East 4152018
East5502018
West1302018
West2352018
West3522018
West4482018
West5602018
East 1322019
East2342019
East 3452019
East 4652019
East5472019 
West1542019
West2492019
West3602019
West4762019
West5782019
East 1342020
East2392020
East 3 2020
East 4 2020
East5 2020
West1422020
West2502020
West3 2020
West4 2020
West5 2020

 

If today is the 1st day of my campaign, this is how my output should like:

Region201820192020
East253234
West305442

 

and when the data for 2020 automatically refreshes for 2nd day of campaign, my output should look like:

Region201820192020
East203439
West354950

 

How can I do this in powerbi?

5 REPLIES 5
amitchandak
Super User
Super User

@jazzk , Prefer to a separate table for Campaign Day

 

Try measures like

 

Campaign value =
var _max = maxX(allselected('Campaign'), 'Campaign'[Campaign Day])
return
CALCULATE(sum('order'[Qty]),filter(ALL('Campaign'),'Campaign'[Campaign Day]=_max))

Campaign value =
var _max = maxX(allselected('Campaign'), 'Campaign'[Campaign Day])
return
CALCULATE(sum('order'[Qty]),filter(ALLSelected('Campaign'),'Campaign '[Campaign Day]=_max))

Campaign value =
var _max = maxX(allselected('Campaign'), 'Campaign'[Campaign Day])
return
CALCULATE(sum('order'[Qty]),filter('Campaign ','Campaign'[Campaign Day]=_max))

@amitchandak I'm looking for the sum of amount for each year based on the day the campaign is running.

 

Greg_Deckler
Super User
Super User

@jazzk - Seems like a Running Total quick measure? Put DayAmount in your visual, click the little drop down area in the Fields area, choose Quick Measure, choose Running Total, and use Campaign Day for your "date" essentially.


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

@Greg_Deckler I don't think a running total would provide me the expected output as I want the sum of amount to be updated based on the campaign day as mentioned in the question.

@jazzk - Ahh, you want Lookup Min/Max then, a value as of the "latest", "maximum", "minimum" of something. https://community.powerbi.com/t5/Quick-Measures-Gallery/Lookup-Min-Max/m-p/985814#M434


@ me in replies or I'll lose your thread!!!
Instead of a Kudo, please vote for this idea
Become an expert!: Enterprise DNA
External Tools: MSHGQM
YouTube Channel!: Microsoft Hates Greg
Latest book!:
The Definitive Guide to Power Query (M)

DAX is easy, CALCULATE makes DAX hard...

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.

Top Solution Authors